Reputation: 2124
I have a code what has a simple select/options and some check boxes i want to send to server using PHP script, all the options including the option selected ( so i cant make them all selected ) so how do i do it?
Upvotes: 0
Views: 169
Reputation: 8838
Keep your dropdown as it is.
<select id="location" name="location">
.
.
.
.
</seelct>
Then add another one dropdown as hidden (display:none;)
without any options. This dropdown will be filled with options when clicking submit button.
On submit button click action add below js code,
In js:
$('#location option').clone().appendTo('#near_location');// copied all options
var index = $('#location ').get(0).selectedIndex; // remove selected
$('#near_location option:eq(' + index + ')').remove();
return true;
Now you will get the selected option in $_POST["location"]
and un-selected values in $_POST["near_loaction"]
.
Upvotes: 1
Reputation: 422
You can save generated options on the server via session or database and load it after submit.
Upvotes: 0