So I have a dropdown menu with 'Next' and 'Prev' (previous) buttons. I would like it so upon pressing next or prev it would also submit the dropdown choice.
<input type="button" id="change2" value="prev" />
<select id="Questions">
<option value="QA">QUESTION A</option>
<option value="QB">QUESTION B</option>
<option value="QC">QUESTION C</option>
<option value="QD">QUESTION D</option>
</select>
<input type="button" id="change" value="next" />
And here is the JQuery for it:
$(window).load(function(){
var dd = $('#Questions'),
max_len = dd.find('option').length;
$('#change').click(function () {
var x = dd.find('option:selected').index();
if (max_len == x + 1) {
x = -1;
}
dd.find('option').eq(x + 1).prop('selected', true);
});
$('#change2').click(function () {
var x = dd.find('option:selected').index();
if (max_len == x + 1) {
x = -1;
}
dd.find('option').eq(x - 1).prop('selected', true);
})
});
How can I make it so that when I click next or prev it submits the form too?
Thanks