I want to show names of the employee in drop down list fetched from database depending on type of team checked by the user (Teams like Hr,PD,PI) are in the form of checkboxes .how can i do this? the code m using is:-

`<li><input type="checkbox" name="box[]" value="Ac&Admin" onClick="dropdown(0)" />Ac&Admin</li>

     <li><input type="checkbox" name="box[]" value="HR" onClick="dropdown(2)"/>HR</li>
     <li><input type="checkbox" name="box[]" value="pd" onClick="dropdown(3)" />PD</li>
     <li><input type="checkbox" name="box[]" value="pi" onClick="dropdown(4)"/>PI</li>`

    <td class=bleu align=left>Name</td>
    <td valign="middle" align=left >
    <select name=cmbname id="cmbname" width='50%'>
        <option value='ALL' selected >ALL</option>
    $objContext =  c_Context::BuildContext('attendance1'); 
        $objDB      =  $objContext->GetDB();       

        $sql="Select empname from mstEmp ";
                foreach ($cbox as $key => $value)
                        $sql.="where teamtype= 'HR'"; 

                        else if($value=='Gaurd')
                        $sql.="where teamtype= 'Gaurd'";

                        else if($value=='Ac&Admin')
                        $sql.="where teamtype= 'Ac&Admin'";

                        else if($value=='pd')
                        $sql.="where teamtype= 'PD'";

                        else if($value=='Visitor')
                        $sql.="where teamtype= 'Visitor'";

                        else if($value=='pi')
                        $sql.="where teamtype= 'PI'";

                        else if($value=='pt')
                        $sql.="where teamtype= 'PT'";

                        $sql.="where teamtype= 'Specialist'";
        $res = $objDB->GetQueryReference();

        exit("Error in SQL : $sql");

        if($objDB->GetNumRows($res) == 0)
        exit("No employee records\n<BR>");

        while($row = mysql_fetch_row($res))
             print("<option value='{$row[0]}'>{$row[0]}</option>");



You would need to use AJAX to retrieve the new values for the dropdown. Basically, turn this PHP code into a file of it's own, and pass the values that are selected to build your query condition.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.