473,395 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Transferring value from one select box to another

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[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);
}
}
}
</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

Jul 20 '05 #1
1 4805
essayez de parcourir la liste des options dans le sens Imax => Imin

for(var i=srcObj.length; i=0; i--)

vérifier les limites dans ma proposition
Bonne chance
GR

Raghuram Banda a écrit:
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[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);
}
}
}
</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


Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of...
1
by: vikram | last post by:
What is the best way of transferring values from one aspx page to another when user click a button, except response.redirect and server.transfer.
15
by: http://www.visual-basic-data-mining.net/forum | last post by:
Does anyone have any idea how to transferring data from TextBox1 in form1 to textBox2 in form2..... That means after i fill in any data in textBox1 and click Next button... It will bring me to...
2
by: neilr | last post by:
Can anyone help with some problkems that have wasted 2 days of my (inexperienced) time already? We have a website which allows people to register for events like conferences We are importing...
5
by: meetalps | last post by:
Hi All, Can you please help me with a step by step procedure to transfer files from my PC to DB2-AIX and vice versa. I am new to both. Example transferring a sql file to run from PC to DB2 on AIX....
1
by: R.A.M. | last post by:
Hi, I am learning ASP.NET and I need to have an Excel-like sheet of records from database. Users may modify data in the sheet. I thought about using GridView with DataSource but the problem is...
2
by: keeps21 | last post by:
I have a script that recieves an id number via the address bar when a link is clicked. ie . index.php?id=1 if the link was for the story whose ID is 1. My script checks if a user is logged in,...
2
by: grego9 | last post by:
I have a problem in Excel 2000. I have written some VBA code that transfers data from the current excel workbook to a file called "Deal Input2.xls". Everything transfers ok apart from the date in...
3
by: janetopps | last post by:
I have a news website, with asp pages, which was on Access, and i upgraded to MySQL, i used Bullzip to transfer the data. It had about 1000 pages, which im now able to pull up on the public side. Im...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.