dropdown list based on checkbox

i have few checkboxes named as HR,visitor,gaurd now i want to get which ever chckbox is selected according to it names of the employee belonging to that team whether HR or Guard or visitor to be shown in dropdown list

<select name=cmbname id="cmbname" width='50%'>

ALL

`

    $objDB->SetQuery($sql);

    $res = $objDB->GetQueryReference();

    if(!$res)
        exit("Error in SQL : $sql");

    if($objDB->GetNumRows($res) > 0)
    {
        while($row = mysql_fetch_row($res))
        {

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

        }
    }
    mysql_free_result($res);

?>'

Answers


Himani ,

Try this. Hope it will be useful to you. Instead of text-area you can use drop-down.


Try this way gives you solution

 <script type="text/javascript">
 //javascript 
 function clicked_checkbox()
 {  
   document.form.submit();  
 }
 </script>
 <?php
 $hr = isset($_REQUEST['HR'])?$_REQUEST['HR']:false;
 $guest = isset($_REQUEST['guest'])?$_REQUEST['guest']:false;
 $visiter = isset($_REQUEST['visiter'])?$_REQUEST['visiter']:false;

//Prepare query with retrieved value and put value in Dropdown
$sql = 'select * from table ';
if($hr)      { $sql .= "where user = '$hr'" };
if($guest)   { $sql .= "where user = '$guest'" };
if($visiter) { $sql .= "where user = '$hr'" };

$objDB->SetQuery($sql);
$res = $objDB->GetQueryReference();

if(!$res)
    exit("Error in SQL : $sql");

if($objDB->GetNumRows($res) > 0)
{
    while($row = mysql_fetch_row($res))
    {
        print("<option value='{$row[0]}'>{$row[0]}</option>");
    }
}
mysql_free_result($res);
?>

//on change of checkbox we'll call above function and set data to dropdown
<form name='form' method='get' action='#'>
<input type="checkbox" id="checkbox_HR" name="HR" value="true" <?php if($hr) echo "checked='checked'"; ?> onchange="return clicked_checkbox();">
 <input type="checkbox" id="checkbox_guest" name="guest" value="true" <?php if($guest) echo "checked='checked'"; ?> onchange="return clicked_checkbox();">
  <input type="checkbox" id="checkbox_user" name="visiter" value="true" <?php  if($visiter) echo "checked='checked'"; ?> onchange="return clicked_checkbox();">
 </form>

like this you can achieve :)


Need Your Help

Matlab/Simulink: Determine current system level

matlab simulink

In Matlab/Simulink, is there a convenient way to determine the depth of the current system, i.e. the numbers of system block borders one has to cross to reach the root level from there? I suppose y...

DirectX 11: Null Swap Chain

c++ directx directx-11

so I am learning DirectX 11 and I was making stuff and I came across a debugging error (trying to access 0x00000000 from the swap chain) and I thought the CreateDeviceAndSwapChain was supposed to fix