Like my other post my form allows the user
In my form I have 2 dropdownlists that allow multiple selections, i need to put the users selections into a hidden textbox so i can pass the values to the next page via post. I cannot use $_POST['languages'] to get the values as it returns all the users selections form the all the dropdowns as a single array and i cannot tell what values came from what dropdown. So my thinking is to use jquery to populate a hidden textbox, however my code doesnt work once i add another dropdown. I tried using class="languages" and .languages but this doesnt work.
Here is the POST result for the dropdown.
Here is my code for the dropdown.Code:["languages"]=> array(7) { => string(9) "Bulgarian" [1]=> string(7) "English" [2]=> string(7) "Finnish" [3]=> string(6) "French" [4]=> string(7) "English" [5]=> string(7) "Finnish" [6]=> string(6) "French" }
Code:<script> function addTableRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; if(rowCount < 10){ var row = table.insertRow(rowCount); var colCount = table.rows[0].cells.length; for(var i=0; i<colCount; i++) { var newcell = row.insertCell(i); newcell.innerHTML = table.rows[0].cells[i].innerHTML; }}else{ alert("Maximum number is 10"); }} $(function(){ $( "#txtdate" ).datepicker({ dateFormat: 'dd/mm/yy', yearRange: "2016:2020", showOtherMonths: true, selectOtherMonths: true}); }); </script> <input type="button" value="add row" onClick="addTableRow('tbl')"> <table id="tbl"> <tr><td> <input type="hidden" name="txtlang[]" id="txtlang"> <label for="languages" class="languages">Select Required Languages</label> <?php $languages = getLanguageList();?> <select name="languages[]" id="languages" multiple> <?php foreach ($languages as $key => $value){ echo "<option value=\"".$key."\">".$value."</option>"; } ?> </select> <script type="text/javascript"> function getLanguageSelection() { var langSelection = $( "#languages" ).val() || []; $( "#txtlang" ).val( langSelection.join( ", " )); } $( "#languages" ).change( getLanguageSelection ); </script>



Reply With Quote
