I have two dropdown boxes in one form – only one option can be selected from each box. On pressing the submit button of the form, I want to store the values of the options selected in two different variables.
Here is my form:
<form id="form1" method="post">
<select id="slt_country" name="country">
<option value="EN" >England</option>
<option value="SC" >Scotland</option>
<option value="IR" >Ireland</option>
</select>
<select id="slt_zoom" name="zoom">
<option value="IC" >close</option>
<option value="SC" >far</option>
</select>
<input type="submit" Value="submit" >
</form>
And this is what I have come up with so far to retrieve the form:
$("#form1").submit (function(){
var ctry= $("select#slt_country").val();
var zm= $("select#slt_zoom").val();
});
I’ve been struggling for too long now with something that should be so simple, so decided to ask for help.
Try again. It should work! 😉