CodeIgniter Forums
I HAVE PROBLEM WITH MULTIPLE COMBOBOXES - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: I HAVE PROBLEM WITH MULTIPLE COMBOBOXES (/thread-23237.html)



I HAVE PROBLEM WITH MULTIPLE COMBOBOXES - El Forum - 10-04-2009

[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'][email protected]$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'][email protected]$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!


I HAVE PROBLEM WITH MULTIPLE COMBOBOXES - El Forum - 10-04-2009

[eluser]jedd[/eluser]
Were you thinking about using any CodeIgniter stuff in your application?


I HAVE PROBLEM WITH MULTIPLE COMBOBOXES - El Forum - 10-04-2009

[eluser]AlexPOWER[/eluser]
What are you mean Codeigniter?
I want to add product.
First i want to select in which category ,user can add product.

For exampel
first user select category, and than subcategory,and so on.
user must select, from 5 dropdown boxes(category and subcategory).

but i want to filterout results, i mean if user select option from first drop,which is main category, in second drop will show just options from selected category.


I HAVE PROBLEM WITH MULTIPLE COMBOBOXES - El Forum - 10-05-2009

[eluser]AlexPOWER[/eluser]
[quote author="jedd" date="1254708326"]Were you thinking about using any CodeIgniter stuff in your application?[/quote]