I have two MultiSelect lists (AllProductList and SelectedProductList), AllProductList contains all products for a particular category and I add/clone options from the AllProductList to the SelectedProductList using JQuery.
I obviously only wish to post the values in the SelectedProductList and irrespective of whether they are selected or not.
I have wrapped the form tags around the SelectedProductList only and now need some way to post all option values in it, irrespective whether selected or not.
Under Insert controls, click Multiple-Selection List Box. If you cleared the Automatically create data source check box in step 3, select a repeating field in the Multiple-Selection List Box Binding dialog box to which you want to bind the multiple-selection list box.
you could write some javascript that fills a hidden form element with all the values from the select, something like below, and on the serverside just use explode(",",$_POST["allValues"]) to get all options
<script>
var hiddenValues = "";
$(document).ready(function(){
$("#mySelect option").each(function(){
hiddenValues = $(this).val() + ",";
})//end each
$("#myForm").append("<input type='hidden' name='allValues' value='"+hiddenValues+"'>")
})
</script>
obviously, the above has a dependency on jQuery and your form has a id of myForm and that your multiselect has a id of mySelect :)
EDIT :
NOTE1 : that this saves only the values of the options, and not the labels from the select (a similiar method can be employed to save those as well). just keep this in mind
NOTE2 : beware if the values contain any commas, as this will invalidate your input (if not escaped in a way, or if not using some other delimiter)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With