Hi,
Here's the function I am using to change the value of one select to another....
PHP Code:
function transferItem(srcId, destId) { var destObj = document.getElementById(destId); var srcObj = document.getElementById(srcId); for(var i=0; i<srcObj.length; i++) if(srcObj.options[i].selected) { var srcTxt = srcObj.options[i].text; var srcVal = srcObj.options[i].value; var newOpt = document.createElement("OPTION"); newOpt.text = srcTxt; newOpt.value = srcVal; destObj.add(newOpt, null); } for(var i=0; i<srcObj.length; i++) { if(srcObj.options[i].selected) { srcObj.remove(i); } } }
I can see it is transferring one select to another but when I check the source....I shows empty.....
Please help...
Here's the code how I am calling it...
HTML Code:
<select name="cat[]" id="cat" multiple="multiple" size="10" style="width: 200px;">
<option onKeyPress="" value="Select City">Select Category</option>
</select>
<input name="insert" type="button" onClick='transferItem("cat","cat2") ' class="btm" value="Insert" /></td>
<input name="delete" type="button" onClick='transferItem("cat2","cat") ' class="btm" value="Delete" />
<select name="cat2[]" id="cat2" multiple="multiple" size="10" style="width: 200px;">
</select>
In the last:
This is how I am calling this array:
PHP Code:
if(!empty($_POST['cat2'])) { for($i=0; $i<sizeof($_POST['cat2']); $i++) { $list1[$i] = $_POST['cat2'][$i]; }
Please help.....Thanks..
Last edited by Isabella_Smith; 04-07-2010 at 05:47 AM..
|