javascript - Change items in a drop-down list depending on the selected option in another drop-down list -
i have following code:
<select name="trec"> <? $d -> gettreatment(); ?> </select> <select name="treratment"> <? $d -> gettreat(); ?> </select>
the <? $d -> gettreatment(); ?>
will display echo "<option value='$r[id]'>$r[cat]</option>";
and <? $d -> gettreat(); ?>
will display echo "<option value='$r[id]'>$r[treatment]</option>";
how dynamically narrow down (or limit) items in second drop down list based on selected item first selected item? example if have 1 list of countries in first drop down list , have list of states in second list once usa selected country list second list should change list states of usa
<script type="text/javascript"> $(function() { $("#form_process").click(function() { //$("#choice").val(); //you cannot use same id more 1 tag var choice = 0; if(document.getelementbyid("choice1").checked) choice='yes'; else if(document.getelementbyid("choice2").checked) choice='no'; else if(document.getelementbyid("choice3").checked) choice='dont know'; var comments = document.getelementbyid('comments').value; //$("#comments").val(); var datastring = 'choice='+ choice + '&comments=' + comments; $.ajax({ type: "post", url: "**absolute url processor**", data: datastring }); }); }); </script>
Comments
Post a Comment