Skip to content Skip to sidebar Skip to footer

Display Checkbox After Select Combo Box

I need some idea here.. i wanted to make search function using combo box. after user has selected certain value from the combo box...based on selected value checkbox will appears..

Solution 1:

Give your select list an ID.

Using jQuery:

$(document).ready(function(){
  $("#mySelect").change(function(){
    var selectValue = $("#mySelect").val();
    switch(selectValue){
      case"someValue":
        var checkbox = '<input type="checkbox" name="something" value="something" />'
        $("#someDiv").append(checkbox);
        break;
      case"someOtherValue":
        var checkbox = '<input type="checkbox" name="something" value="something" />'
        $("#someDiv").append(checkbox);
        break;
    }
  });
});

And so on. Hopefully, you get the idea.

Solution 2:

finally i managed to do... thanks all for your help ... this is what i did

select statement

echo'<select name="SearchCriteria"  id="SearchCriteria" style="font:12px Verdana ; width:150px;" >';                             
    echo'<option value="">Select Search</option>';

     for ($i =0; $i<$rowcount; $i++)  
    {  

     $row = mysql_fetch_array($sql); 
     echo'<option ';
     $value = $row['p_on'];                                     
     echo'value="' . $value . '">' . $value .'</option>';

    }

    echo'</select>';

div and script below the select statement

<divid="Checkbox"></div><script>

 $("select").change(function(){
    var selectValue = $("select").val();
    switch(selectValue){
    case"user":
    var checkbox = '<input type="checkbox" name="something" value="something" />'
    $("#Checkbox").append(checkbox);
    break;
     case"tag":
    var checkbox = '<input type="checkbox" name="something" value="something" />'
    $("#Checkbox").append(checkbox);
    break;
    }
 });

</script>

Post a Comment for "Display Checkbox After Select Combo Box"