Reputation: 1294
I have used name="question[]"
for multiple select box and the same name used for submit button name as name="question[]"
How can I get the values of the select box without the submit button?
Upvotes: 0
Views: 98
Reputation: 602
If you can use a jQuery/Sizzle variant on the front
$('select[name="question[]"]').val();
Will return the selected value from the select box by that name. You can then populate some other field with that value before submitting to the server.
Upvotes: 0
Reputation: 2265
You can get both the elements value as follows,
You can then access it using the following:
$_POST['question'][0];
$_POST['question'][1];
You can get the values of select box and submit button now.
Upvotes: 0
Reputation: 781726
The best solution is to fix the name clash.
If the value
of the submit
button can never be one of the select
values, you can ignore any element of $_POST['question']
that has that value.
Upvotes: 0
Reputation: 83
Change the name of your submit button... it shouldn't be the same.
Upvotes: 1