This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes how to move items in between  two select lists using  javascript ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to move items in between  two select lists using  javascript ???" Watch "how to move items in between  two select lists using  javascript ???" New topic
Author

how to move items in between two select lists using javascript ???

Waez Ali
Ranch Hand

Joined: Jan 24, 2005
Posts: 43
Hi,
I have one select list "LIST1" & two button with label "Right" "Left" now what i want to do is when i click on any item from first list and then click on "Right" button,then that item should be moved to the second Select List "LIST2" which was empty.

<script>
function Move(){

var val = document.frm.LIST1.value;

var element = document.createElement('option');
element.setAttribute('value',val);
document.getElementById('l2').appendChild(element);
alert(document.frm.LIST2.value);
}
</script>

<SELECT name="LIST1" size="4" multiple>
<OPTION value="A1">A</OPTION>
<OPTION value="B2">B</OPTION>
<OPTION value="C3">C</OPTION>
<OPTION value="D4">D</OPTION>
</SELECT>
--- buttons onclick call move()-----


<select id="l2" name="LIST2" size="4" multiple>
</select>



I tried it using javascript but

Somebody please make this code correct
I hope u understand my problem.

Thanks in advance
[ May 02, 2005: Message edited by: Waez Ali ]
Venkatraman Kandaswamy
Ranch Hand

Joined: Jul 07, 2004
Posts: 120
Here is an example you can use.


--Venkatraman<br />SCJP 1.4<br /><a href="http://kvrlogs.blogspot.com" target="_blank" rel="nofollow">blog</a>
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
http://www.mattkruse.com/javascript/selectbox/

Eric
Waez Ali
Ranch Hand

Joined: Jan 24, 2005
Posts: 43
Thanks venkatraman & eric for such a good response.

Waez Ali
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to move items in between two select lists using javascript ???
 
Similar Threads
Is this a bug of IE regarding select?
Passing parameters in XSL to JavaScript
selection box problem
list......jsp, javascript
Passing parameters in XSL to JavaScript