Welcome Guest, Not a member yet? Register   Sign In
I HAVE PROBLEM WITH MULTIPLE COMBOBOXES
#1

[eluser]AlexPOWER[/eluser]
Hi,
I have one table in my database where i store my categories and subcategories...
(like)

id
name
parent


and i want to create dropdown for category and for each under category (total 5 dropdown).

Code:
<html>
<body>
[removed]
function reload(form){
var val=form.cat.options[form.cat.options.selectedIndex].value;
self.location='np.inc.php?cat=' + val;
}
[removed]
<fieldset style="border: 1px dashed blue;">
<legend>Add Product</legend>
    &lt;?php
    ///// Vazeca scripta
    $quer2=mysql_query("SELECT name,id FROM categories WHERE parent = 0 ORDER BY name");
    $cat= $_GET['cat']; //This line is added to take care if your global variable is off
    

    if(isset($cat) and strlen($cat) > 0)
    {
        $quer=mysql_query("SELECT name,id FROM categories WHERE parent = $cat ORDER BY name");
    }
    //check if $cat is numeric data or not.
    if(strlen($cat) > 0 and !is_numeric($cat))
    {
    echo "Data Error";
    exit;
    } */
    
    echo "&lt;form method=post name=form1 action=''&gt;";
    echo "<table cellspacing =\"2\" cellpadding =\"3\">";
    echo "<tr><td>Category</td>";
    echo "<td>";
    ////////// Starting of first drop downlist /////////
    echo "<select name='cat' id='cat'>
        <option value=''>Select one...</option>";
    while($noticia = mysql_fetch_array($quer2))      
    {
        if($noticia['id']==@$cat)
        {
            echo "<option selected value='$noticia[id]'>$noticia[name]</option>"."<BR>";
        }else
            {
                echo "<option value='$noticia[id]'>$noticia[name]</option>";
            }
    }
    echo "</select>";
    ////////////////// This will end the first drop down list ///////////
    echo "</td></tr>";
    
    echo "<tr><td>Sub Category</td>";
    echo "<td>";
    ////////// Starting of second drop downlist /////////
    echo "<select name='subcat' id='subcat'><option value=''>Select one...</option>";
    while($noticia2 = mysql_fetch_array($quer))
    {
    if($noticia2['name']==@$subcat){echo "<option selected value='$noticia2[id]'>$noticia2[name]</option>"."<BR>";}
    echo "<option value='$noticia2[name]'>$noticia2[name]</option>";
    }
    echo "</select>";
    echo "</td></tr>";
    echo "</table>";
    echo "&lt;input type='hidden' value='".htmlspecialchars($cat)."'&gt;";
    echo "&lt;input type=submit value=Submit&gt;";
    echo "&lt;/form&gt;";
    ?&gt;
</fieldset>
&lt;/body&gt;
&lt;/html&gt;

If a user select option from first dropdown,the second one will populate with options for selected option from first dropdown.

PLEASE HOW CAN I DO THAT!
Is that possibile?

PLEASE HELP!


Messages In This Thread
I HAVE PROBLEM WITH MULTIPLE COMBOBOXES - by El Forum - 10-04-2009, 02:01 PM
I HAVE PROBLEM WITH MULTIPLE COMBOBOXES - by El Forum - 10-04-2009, 03:05 PM
I HAVE PROBLEM WITH MULTIPLE COMBOBOXES - by El Forum - 10-04-2009, 04:26 PM
I HAVE PROBLEM WITH MULTIPLE COMBOBOXES - by El Forum - 10-05-2009, 07:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB