This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is an example you can use.
 
author
Posts: 15385
6
 
Waez Ali
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks venkatraman & eric for such a good response.

Waez Ali
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic