DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Help with Drop down list

  1. #1
    Join Date
    Aug 2008

    Help with Drop down list

    I want to change this code so that you can enter "Fruits" in a textr field and the drop down is populated instead of selecting "Fruits" from a drop down.

    <!doctype html public "-//w3c//dtd html 3.2//en">
    <title>Multiple drop down list box from plus2net</title>
    <SCRIPT language=JavaScript>
    function reload(form)
    self.location='dd.php?cat=' + val ;
    If register_global is off in your server then after reloading of the page to get the value of cat from query string we have to take special care.
    To read more on register_global visit.
    @$cat=$_GET['cat']; // Use this line or below line if register_global is off
    //@$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off
    ///////// Getting the data from Mysql table for first list box//////////
    $quer2=mysql_query("SELECT DISTINCT category,cat_id FROM category order by category"); 
    ///////////// End of query for first list box////////////
    /////// for second drop down list we will check if category is selected else we will display all the subcategory///// 
    if(isset($cat) and strlen($cat) > 0){
    $quer=mysql_query("SELECT DISTINCT subcategory FROM subcategory where cat_id=$cat order by subcategory"); 
    }else{$quer=mysql_query("SELECT DISTINCT subcategory FROM subcategory order by subcategory"); } 
    ////////// end of query for second subcategory drop down list box ///////////////////////////
    echo "<form method=post name=f1 action='dd-check.php'>";
    /// Add your form processing page address to action in above line. Example  action=dd-check.php////
    //////////        Starting of first drop downlist /////////
    echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>";
    while($noticia2 = mysql_fetch_array($quer2)) { 
    if($noticia2['cat_id']==@$cat){echo "<option selected value='$noticia2[cat_id]'>$noticia2[category]</option>"."<BR>";}
    else{echo  "<option value='$noticia2[cat_id]'>$noticia2[category]</option>";}
    echo "</select>";
    //////////////////  This will end the first drop down list ///////////
    //////////        Starting of second drop downlist /////////
    echo "<select name='subcat'><option value=''>Select one</option>";
    while($noticia = mysql_fetch_array($quer)) { 
    echo  "<option value='$noticia[subcategory]'>$noticia[subcategory]</option>";
    echo "</select>";
    //////////////////  This will end the second drop down list ///////////
    //// Add your other form fields as needed here/////
    echo "<input type=submit value=Submit>";
    echo "</form>";
    <center><a href=''>PHP SQL HTML free tutorials and scripts</a></center> 

  2. #2
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    Well, you can either set it up so that the textbox responds to the enter key and does what you need, or place a button on the screen that does what you need once they have finished typing in the textbox.

Similar Threads

  1. Drop down list box with SQL server
    By software_develo in forum .NET
    Replies: 3
    Last Post: 02-16-2006, 01:29 PM
  2. making "Class Name" drop list alphabetic
    By Denny Moore in forum .NET
    Replies: 0
    Last Post: 03-27-2002, 07:14 PM
  3. Replies: 5
    Last Post: 08-22-2001, 10:09 AM
  4. Replies: 4
    Last Post: 11-10-2000, 02:02 AM
  5. Replies: 0
    Last Post: 08-11-2000, 08:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center