I have a couple of forms on one page without a form name.
Each form has a select box and a submit button. Whenever the button is clicked I need to get the value of the select box for the particular form where the button was clicked
form example
<form>
<select class="boxes" name="select3">
<option value="5">5</option>
</select>
<input type="submit" align="right" class="btn" value="Add to basket" name="submit">
</form>
My code thus far
$(".btn").click(function(){
if($(this).val() == 'Add to basket'){
var value = $('select[value="select3"] option:selected').val();
alert(value);
return false;
}
});
All forms look the same just with a couple of more fields and different values in the select box.
use
or
instead of
if you wanna make it more unique, give it an ID..