We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42415
    • 115 Posts
    I have a range of 34 districts and 34 postcodes in individually named columns in MySql and xml. A user inputs information on a form and will select only 1 district and 1 postcode (also other information is input). This will leave 33 empty columns for postcodes and districts on this row of MySql.

    What code do I need to add to make the table display (in child rows) only the single district and postcode that has been input and ignore the empty column (district & postcode) values?

    I have TableSorter displaying most of my required data on the front end using the following code:

    <meta charset="utf-8">
        <!-- jQuery -->
    
    
    <!-- Tablesorter: required -->
    <link rel="stylesheet" href="../css/theme.blue.css">
    
    
    <!-- Tablesorter: pager -->
    <link rel="stylesheet" href="../css/jquery.tablesorter.pager.css">
    
    
        <script>
        $(function() {
    
        $(".tablesorter")
        .tablesorter({
        theme : 'blue',
        // this is the default setting
        cssChildRow: "tablesorter-childRow",
    
        // initialize zebra and filter widgets
        widgets: ["zebra", "filter", "pager"],
    
        widgetOptions: {
        // output default: '{page}/{totalPages}'
        // possible variables: {page}, {totalPages}, {filteredPages},                     {startRow}, {endRow}, {filteredRows} and {totalRows}
        pager_output: '{startRow} - {endRow} / {filteredRows} ({totalRows})', // '{page}/{totalPages}'
        pager_removeRows: false,
        // set number of rows to show; make sure to include this
        // value in the select options
        pager_size: 100,  
        // include child row content while filtering, if true
        filter_childRows  : true,
        // class name applied to filter row and each input
        filter_cssFilter  : 'tablesorter-filter',
        // search from beginning
        filter_startsWith : false,
        // Set this option to false to make the searches case sensitive
        filter_ignoreCase : true
      }
    
    });
     // hide child rows
         $('.tablesorter-childRow td').hide();
    
      // Toggle child row content (td), not hiding the row since we are using rowspan
      // Using delegate because the pager plugin rebuilds the table after each page change
      // "delegate" works in jQuery 1.4.2+; use "live" back to v1.3; for older jQuery - SOL
      $('.tablesorter').delegate('.toggle', 'click' ,function(){
    
    // use "nextUntil" to toggle multiple child rows
    // toggle table cells instead of the row
    $(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').toggle();
    
      return false;
      });
    
      // Toggle widgetFilterChildRows option
      $('button.toggle-option').click(function(){
    var c = $('.tablesorter')[0].config.widgetOptions,
    o = !c.filter_childRows;
    c.filter_childRows = o;
    $('.state').html(o.toString());
    // update filter; include false parameter to force a new search
    $('table').trigger('search', false);
    return false;
      });
    });
    </script>
    
    
    <div id="demo">
    
    <div class="pager">
        <img src="../assets/images/first.png" class="first" alt="First" />
        <img src="../assets/images/previous.png" class="prev" alt="Prev" />
        <span class="pagedisplay"></span> <!-- this can be any element, including an input -->
        <img src="../assets/images/next.png" class="next" alt="Next" />
        <img src="../assets/images/last.png" class="last" alt="Last" />
        <select class="pagesize" title="Select page size">
            <option value="10">10</option>
            <option value="20">20</option>
            <option value="30">30</option>
            <option value="40">40</option>
            <option value="50">50</option>
            <option value="100">100</option>
        </select>
        <select class="gotoPage" title="Select page number"></select>
    </div>
    
    <table class="tablesorter">
    <colgroup>
        <col width="85" />
        <col width="110" />
        <col width="110" />
        <col width="100" />
        <col width="100" />
    </colgroup>
    <thead>
        <tr>
            <th>Id No #</th>
            <th>Province</th>
            <th>Date</th>
            <th>Country</th>
            <th>Package Type</th>
        </tr>
    </thead>
    <tbody>
        <!-- First row expanded to reveal the layout -->
    [[+innerrows.row]]
        </tbody>
    </table>
    
       </div>


    I want to add code to the following rowTpl so to include as child rows the only selected district and postcode:

            <tr>
    <td rowspan="4"> <!-- rowspan="4" makes the table look nicer -->
        <a href="#" class="toggle">[[+id]] - More info</a> <!-- link to toggle view of the child row -->
    </td>
    <td>[[+province]]</td>
    <td>[[+date132]]</td>
    <td>[[+country]]</td>
    <td>[[+packagetype]]</td>
    </tr>
    <tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Customer Name</div><div>[[+yourname]]<br></div></td></tr>
    <tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Phone Number</div><div>[[+phonenumber]]<br></div></td></tr>
    <tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Email Address</div><div>[[+email128]]<br></div></td></tr>
    <tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Company Name</div><div>[[+companyname]]<br></div></td></tr>
    <tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Package Weight</div><div>[[+weight]]<br></div></td></tr>
    <tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Package Width</div><div>[[+width]]<br></div></td></tr>
    <tr class="tablesorter-childRow"><td colspan="5"><div class="bold">package Height</div><div>[[+height]]<br></div></td></tr>
    <tr class="tablesorter-childRow"><td colspan="5"><div class="bold">Details</div><div>[[+details]]<br></div></td></tr>


    Here is the xml including the 34 districts and postcodes:

        <model package="shipsaveeng" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
    <object class="ShipSave" table="shipsaveeng" extends="xPDOSimpleObject">
    <field key="id" dbtype="int" precision="11" phptype="integer" null="false" default=""/>
    <field key="province" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district1" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district2" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district3" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district4" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district5" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district6" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district7" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district8" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district9" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district10" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district11" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district12" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district13" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district14" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district15" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district16" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district17" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district18" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district19" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district20" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district21" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district22" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district23" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district24" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district25" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district26" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district27" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district28" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district29" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district30" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district31" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district32" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district33" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="district34" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="postcode1" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode2" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode3" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode4" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode5" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode6" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode7" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode8" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode9" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode10" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode11" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode12" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode13" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode14" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode15" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode16" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode17" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode18" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode19" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode20" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode21" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode22" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode23" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode24" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode25" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode26" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode27" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode28" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode29" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode30" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode31" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode32" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode33" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="postcode34" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="date132" dbtype="date" phptype="date" null="true" default="0000-00-00"/>
    <field key="country" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="phonenumber" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="email128" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="companyname" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="packagetype" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
    <field key="weightkgs" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="width" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="length" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="height" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
    <field key="details" dbtype="text" phptype="string" null="false" default=""/>
    <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
        <column key="id" collation="A" null="false" />
    </index>
        <aggregate alias="Resource" class="modResource" local="resource_id" foreign="id" cardinality="one" owner="foreign" />
        <aggregate alias="Creator" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign" />
    </object>
    </model>


    There is a form on the front end that users fill in http://bit.ly/1BYOLyn

    This data is automatically recorded in the database. The info in the database is displayed automatically in a table on this page http://bit.ly/1LOsSl5

    The users also select 1 district and 1 postcode, but, in the database every district & postcode is there. I want to display in the table only the chosen district & postcode. All the other districts and postcodes are also in their own columns but I want the code to ignore the empty fields where there is no input/value. One user could choose district4 & postcode15, the next user could choose district28 & postcode14. On the front end table I want to display in a child row the actual chosen district & postcode and ignore the 33 district & postcode that were not selected.

    On the actual form the box the district & postcode do not display until on the form a province has been selected.

    The above links are to demo pages and I will delete the links later because this site not launched yet, so it is ok to input dummy data onto the form if you wish to see it displayed in the table.
      • 4172
      • 5,888 Posts
      ok, first things first.

      I'm not sure to understand your database-design and why you need 34 districts and postcode - columns

      Each Entry can have multiple district/zipcode, right?
      Shouldn't it be more like that, then?
      <model package="shipsaveeng" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
      <object class="ShipSave" table="shipsaveeng" extends="xPDOSimpleObject">
          <field key="province" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
          <field key="date132" dbtype="date" phptype="date" null="true" default="0000-00-00"/>
          <field key="country" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
          <field key="phonenumber" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
          <field key="email128" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
          <field key="companyname" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
          <field key="packagetype" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
          <field key="weightkgs" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
          <field key="width" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
          <field key="length" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
          <field key="height" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
          <field key="details" dbtype="text" phptype="string" null="false" default=""/>
      
          <composite alias="Postcodes" class="ShipSavePostcode" local="id" foreign="shipsave_id" cardinality="many" owner="local" />
      </object>
      
      <object class="ShipSavePostcode" table="shipsaveeng_postcodes" extends="xPDOSimpleObject">
          <field key="district" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
          <field key="postcode" dbtype="varchar" precision="11" phptype="string" null="false" default="" index="index" />
          <field key="shipsave_id" dbtype="int" precision="10" phptype="integer" null="false" default="" index="index" />
      
          <aggregate alias="ShipSave" class="ShipSave" local="shipsave_id" foreign="id" cardinality="one" owner="foreign" />
      </object>
      
      </model>
      


      Then it would be much easier to search and more scalable. [ed. note: Bruno17 last edited this post 11 years, 3 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 42415
        • 115 Posts
        Quote from: Bruno17 at Jun 28, 2015, 11:38 PM
        ok, first things first.

        I'm not sure to understand your database-design and why you need 34 districts and postcode - columns

        Each Entry can have multiple district/zipcode, right?
        Shouldn't it be more like that, then?
        <model package="shipsaveeng" baseclass="xPDOObject" platform="mysql" defaultengine="MyISAM" version="1.1">
        <object class="ShipSave" table="shipsaveeng" extends="xPDOSimpleObject">
            <field key="province" dbtype="varchar" precision="255" phptype="string" null="false" default="">
            <field key="date132" dbtype="date" phptype="date" null="true" default="0000-00-00">
            <field key="country" dbtype="varchar" precision="255" phptype="string" null="false" default="">
            <field key="phonenumber" dbtype="varchar" precision="255" phptype="string" null="false" default="">
            <field key="email128" dbtype="varchar" precision="255" phptype="string" null="false" default="">
            <field key="companyname" dbtype="varchar" precision="255" phptype="string" null="false" default="">
            <field key="packagetype" dbtype="varchar" precision="255" phptype="string" null="false" default="">
            <field key="weightkgs" dbtype="decimal" precision="11.0" phptype="string" null="false" default="">
            <field key="width" dbtype="decimal" precision="11.0" phptype="string" null="false" default="">
            <field key="length" dbtype="decimal" precision="11.0" phptype="string" null="false" default="">
            <field key="height" dbtype="decimal" precision="11.0" phptype="string" null="false" default="">
            <field key="details" dbtype="text" phptype="string" null="false" default="">
        
            <composite alias="Postcodes" class="ShipSavePostcode" local="id" foreign="shipsave_id" cardinality="many" owner="local">
        </composite></field></field></field></field></field></field></field></field></field></field></field></field></object>
        
        <object class="ShipSavePostcode" table="shipsaveeng_postcodes" extends="xPDOSimpleObject">
            <field key="district" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index">
            <field key="postcode" dbtype="varchar" precision="11" phptype="string" null="false" default="" index="index">
            <field key="shipsave_id" dbtype="int" precision="10" phptype="integer" null="false" default="" index="index">
        
            <aggregate alias="ShipSave" class="ShipSave" local="shipsave_id" foreign="id" cardinality="one" owner="foreign">
        </aggregate></field></field></field></object>
        
        </model>
        


        Then it would be much easier to search and more scalable.

        The reason the form has 34 districts and 34 postcodes (each representing a column in MySql) is there are 34 provinces, after select province in the form it opens 2 boxes containing all the districts within that province and the total range of postcodes for that province. Click on a different province & it opens up the unique set of districts & range of postcodes for that province.

        In the form I cannot change the field key for these districts & postcodes because it has to be unique. The design request is for the districts and postcodes only to appear after the province has been selected.
        Performance is not an issue because this table page will eventually be on a password protected web page with only 2 staff regularly accessing the page.

        To implement the xml you have placed here I am assuming 1 of 2 things;

        I run this xml through MIGX and create 2 extra lines in rowTpl to include [[+district]] & [[+postcode]]?
        or
        I would have to change both sets of the 34 field keys to "district" & "postcode"?

        As I cannot do the latter is first assumption correct? or have I missed the point?
          • 42415
          • 115 Posts
          Or do I change this line;

          </composite></field></field></field></field></field></field></field></field></field></field></field></field></object>


          to

          </composite></district1></district2></district3></district4></district5></district6></district7></district8></district9></district10></district11></district12></district13>


          up to 34

          and the same for postcodes

          That kind of makes sense to me.....
            • 4172
            • 5,888 Posts
            has each entry with companyname,phonenumber etc. only one postcode or can each entry have multiple postcodes assigned?
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 42415
              • 115 Posts
              Only one postcode per submission & one district per submission.
              The user selects from the drop down one district and one postcode.
                • 4172
                • 5,888 Posts
                well, then it should be like that.
                You need a table with all province/district/postcode - combinations.
                The submission-record needs only to know the selected id of the postcode.
                Nothing else.

                <model package="shipsaveeng" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                <object class="ShipSave" table="shipsaveeng" extends="xPDOSimpleObject">
                
                    <field key="postcode_id" dbtype="int" precision="10" phptype="integer" null="true" index="index" />
                
                    <field key="date132" dbtype="date" phptype="date" null="true" default="0000-00-00"/>
                    <field key="country" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    <field key="phonenumber" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    <field key="email128" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    <field key="companyname" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    <field key="packagetype" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                    <field key="weightkgs" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
                    <field key="width" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
                    <field key="length" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
                    <field key="height" dbtype="decimal" precision="11.0" phptype="string" null="false" default=""/>
                    <field key="details" dbtype="text" phptype="string" null="false" default=""/>
                 
                    <aggregate alias="Postcode" class="ShipSavePostcode" local="postcode_id" foreign="id" cardinality="one" owner="foreign" />
                </object>
                 
                <object class="ShipSavePostcode" table="shipsaveeng_postcodes" extends="xPDOSimpleObject">
                    <field key="district" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
                    <field key="postcode" dbtype="varchar" precision="11" phptype="string" null="false" default="" index="index" />
                    <field key="province" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
                
                    <aggregate alias="ShipSave" class="ShipSave" local="id" foreign="postcode_id" cardinality="one" owner="local" />
                </object>
                 
                </model>
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 42415
                  • 115 Posts
                  Quote from: Bruno17 at Jun 30, 2015, 03:01 AM
                  well, then it should be like that.
                  You need a table with all province/district/postcode - combinations.
                  The submission-record needs only to know the selected id of the postcode.
                  Nothing else.

                  <model package="shipsaveeng" baseclass="xPDOObject" platform="mysql" defaultengine="MyISAM" version="1.1">
                  <object class="ShipSave" table="shipsaveeng" extends="xPDOSimpleObject">
                  
                      <field key="postcode_id" dbtype="int" precision="10" phptype="integer" null="true" index="index">
                  
                      <field key="date132" dbtype="date" phptype="date" null="true" default="0000-00-00">
                      <field key="country" dbtype="varchar" precision="255" phptype="string" null="false" default="">
                      <field key="phonenumber" dbtype="varchar" precision="255" phptype="string" null="false" default="">
                      <field key="email128" dbtype="varchar" precision="255" phptype="string" null="false" default="">
                      <field key="companyname" dbtype="varchar" precision="255" phptype="string" null="false" default="">
                      <field key="packagetype" dbtype="varchar" precision="255" phptype="string" null="false" default="">
                      <field key="weightkgs" dbtype="decimal" precision="11.0" phptype="string" null="false" default="">
                      <field key="width" dbtype="decimal" precision="11.0" phptype="string" null="false" default="">
                      <field key="length" dbtype="decimal" precision="11.0" phptype="string" null="false" default="">
                      <field key="height" dbtype="decimal" precision="11.0" phptype="string" null="false" default="">
                      <field key="details" dbtype="text" phptype="string" null="false" default="">
                   
                      <aggregate alias="Postcode" class="ShipSavePostcode" local="postcode_id" foreign="id" cardinality="one" owner="foreign">
                  </aggregate></field></field></field></field></field></field></field></field></field></field></field></field></object>
                   
                  <object class="ShipSavePostcode" table="shipsaveeng_postcodes" extends="xPDOSimpleObject">
                      <field key="district" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index">
                      <field key="postcode" dbtype="varchar" precision="11" phptype="string" null="false" default="" index="index">
                      <field key="province" dbtype="varchar" precision="255" phptype="string" null="false" default="">
                  
                      <aggregate alias="ShipSave" class="ShipSave" local="id" foreign="postcode_id" cardinality="one" owner="local">
                  </aggregate></field></field></field></object>
                   
                  </model>

                  Hi Bruno,

                  Am I correct in thinking that to use this code I would have to change the field key outputs on the form so there is only 1 column in MySql for district and 1 column for postcode?

                  The form outputs would have to match these field keys, Yes?:

                  <field key="district" dbtype="varchar" precision="255" phptype="string" null="false" default="" index="index" />
                  <field key="postcode" dbtype="varchar" precision="11" phptype="string" null="false" default="" index="index" />
                  <field key="province" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>

                  If your answer is yes, then I will have to redesign the form because it has 34 outputs (field keys) for postcodes
                  and 34 outputs for districts.

                  Currently there is only 1 form box for province so there would be no need to change this field key.
                    • 4172
                    • 5,888 Posts
                    How do you generate the form currently?
                    With a script or manually?

                    Are you using formit and a hook-snippet to store the submission or something else?

                    Can you show the code, what you are using currently?
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 42415
                      • 115 Posts
                      Quote from: Bruno17 at Jul 01, 2015, 08:42 AM
                      How do you generate the form currently?
                      With a script or manually?

                      Are you using formit and a hook-snippet to store the submission or something else?

                      Can you show the code, what you are using currently?

                      Hi Bruno,

                      I am using an external form not generated within Modx, I just copy & paste the form script into the html file. It is Coffee Cup Web Form Builder, I love the ease of use of this form so much I hacked some of the generated php files to change the (field key="id") so i could integrate its output with Migx (different project last year).

                      That's why when I created 34 different district form boxes I had to create 34 different field keys for each one, same with the 34 different postcode form boxes. Only one of the 34 district & 34 postcode boxes appear in the form after select a Province has been selected.