R
Raghuram Banda
Hi All,
Can any one please look into the following code and tell me where I went
wrong
<html>
<head>
<script language="JavaScript">
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.selected) {
var srcTxt = srcObj.options.text;
var srcVal = srcObj.options.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.selected) {
srcObj.remove(i);
}
}
}
</script>
<body>
<table width="100%" height="335">
<tr>
<td width="33%" height="329">
<select name="sourceSelect" id="sourceSelect" size="4" Multiple>
<option value ="volvo">Volvo</option>
<option value ="saab">Saab</option>
<option value ="opel">Opel</option>
<option value ="audi">Audi</option>
</select>
</td>
<td width="33%" height="329">
<button onClick='transferItem("sourceSelect","destSelect")'> Add
</button>
<br>
<br>
<button onClick='transferItem("destSelect","sourceSelect")'> Remove
</button>
</td>
<td width="33%" height="329">
<select name="destSelect" id="destSelect" size="3" Multiple>
</select>
</td>
</tr>
</table>
</body>
</html>
Actually I have written the script to transfer the selected options
single/multiple(contiguous/non-contiguous) from source select box
to destination select box and vice versa.
This code is working fine in NN6+, the problem is when I'm selecting
contiguous options from source/destination select
box and click on add/remove button I'm gettting problem not all selected
options are deleted from source select box.
Sorry for lengthy mail.
Thanks in advance
Can any one please look into the following code and tell me where I went
wrong
<html>
<head>
<script language="JavaScript">
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.selected) {
var srcTxt = srcObj.options.text;
var srcVal = srcObj.options.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.selected) {
srcObj.remove(i);
}
}
}
</script>
<body>
<table width="100%" height="335">
<tr>
<td width="33%" height="329">
<select name="sourceSelect" id="sourceSelect" size="4" Multiple>
<option value ="volvo">Volvo</option>
<option value ="saab">Saab</option>
<option value ="opel">Opel</option>
<option value ="audi">Audi</option>
</select>
</td>
<td width="33%" height="329">
<button onClick='transferItem("sourceSelect","destSelect")'> Add
</button>
<br>
<br>
<button onClick='transferItem("destSelect","sourceSelect")'> Remove
</button>
</td>
<td width="33%" height="329">
<select name="destSelect" id="destSelect" size="3" Multiple>
</select>
</td>
</tr>
</table>
</body>
</html>
Actually I have written the script to transfer the selected options
single/multiple(contiguous/non-contiguous) from source select box
to destination select box and vice versa.
This code is working fine in NN6+, the problem is when I'm selecting
contiguous options from source/destination select
box and click on add/remove button I'm gettting problem not all selected
options are deleted from source select box.
Sorry for lengthy mail.
Thanks in advance