select box query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SSG001
    New Member
    • Oct 2007
    • 110

    select box query

    i have two seelct boxes in one row as below
    [HTML]</form>
    <table>
    <tr><td>
    <select name="countryco de" id="countrycode " onchange="showc ountrycode
    (this.value);">
    <option selected>select country</option>
    </select>
    <p>ths option are fille dhere fromt eh mysql table using query</p>
    </td>
    <td>
    <select name="citycode" id="citycode" onchange="showc ity(this.value) ;">
    <option selected>select city</option>
    </select>
    </td>
    </tr>
    </table>
    </form>[/HTML]
    i have seen some examples using ajax but the options are defines there i want to use $countrycode to fetch cities from the city mysql table


    Thanks
  • Ranjan kumar Barik
    New Member
    • Aug 2007
    • 95

    #2
    Originally posted by SSG001
    i have two seelct boxes in one row as below
    [HTML]</form>
    <table>
    <tr><td>
    <select name="countryco de" id="countrycode " onchange="showc ountrycode
    (this.value);">
    <option selected>select country</option>
    </select>
    <p>ths option are fille dhere fromt eh mysql table using query</p>
    </td>
    <td>
    <select name="citycode" id="citycode" onchange="showc ity(this.value) ;">
    <option selected>select city</option>
    </select>
    </td>
    </tr>
    </table>
    </form>[/HTML]
    i have seen some examples using ajax but the options are defines there i want to use $countrycode to fetch cities from the city mysql table


    Thanks
    Hi,
    Do you want that the name and id of the select boxes should be a variable $countrycode and the value assigned to it should be fetched from table.

    Thanks!
    :)

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by SSG001
      i have two seelct boxes in one row as below
      [HTML]</form>
      <table>
      <tr><td>
      <select name="countryco de" id="countrycode " onchange="showc ountrycode
      (this.value);">
      <option selected>select country</option>
      </select>
      <p>ths option are fille dhere fromt eh mysql table using query</p>
      </td>
      <td>
      <select name="citycode" id="citycode" onchange="showc ity(this.value) ;">
      <option selected>select city</option>
      </select>
      </td>
      </tr>
      </table>
      </form>[/HTML]
      i have seen some examples using ajax but the options are defines there i want to use $countrycode to fetch cities from the city mysql table


      Thanks
      Which Server Side scripting you are using.
      If that is Java based then I can help other wise I can't.
      If you want to get those values while the page gets processed on Server Side then it can be done simply using Server Side Scripting.
      But if you want to get those information after the page loaded then you have to use Ajax.

      Debasis Jana

      Comment

      • SSG001
        New Member
        • Oct 2007
        • 110

        #4
        i will select countrycode from select box and post this value using ajax ,php,javascript now this values is stored in $countrycode so while fetching the data for cities i'll use this to build query.

        actually i have a main form on which both the select boxes are given and the country is filled with mysql country table
        now i have used ajax and javascript to post this value without refreshing as i have n number of rows of this type and i can't aford let it refresh after evry rows country code is selected .
        which is passed to country.js file through showcountry function
        and from there to country.php to fetch the record for country details depending upon country code and display it .here i also want that depending upon the country code i want the city select box to be filled along with country details display


        [HTML]</form>
        <table>
        <tr><td>
        <select name="countryco de" id="countrycode " onchange="showc ountrycode
        (this.value);">
        <option selected>select country</option>
        </select>
        </td>
        <td><input type="text" name="countryna me" id="countryname " ></td>
        <td><input type="text" name="env" id="env" ></td>
        <td>
        <select name="citycode" id="citycode" onchange="showc ity(this.value) ;">
        <option selected>select city</option>
        </select>
        </td>
        </tr>
        </table>
        <table align="center"> <tr>
        <td colspan="5"><in put type ='button' value='add row' name='addrow' id="addrow" onClick='add_ro ws(document.get ElementById("tb l1"),this.id);' ></td>
        </tr></table>
        </form>[/HTML]

        //my country.js file
        [CODE=javascript]function addrow(tbl,tb){
        }


        function showcountrycode (code)
        {
        //to pass code to country.php
        }


        }[/CODE]
        //country.php
        [PHP]$countrycode=$_ GET['code'];
        //1.select query to fetch details from country table using countrycode
        //2.select query to fetch cities from city table using countrycode
        //and fill the records in the select box
        echo $countryname"|" .$env
        //i have managed to display country name after assiging xmlresponse split value from javascript country.js bt don't know to how to do select box value filling [/PHP]

        Comment

        Working...