wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Copy Element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Copy Element" Watch "Copy Element" New topic
Author

Copy Element

YuenLian Wu
Ranch Hand

Joined: Nov 16, 2005
Posts: 73
Hi all,

I have a combo box contains data loaded from server side. I want to duplicate this combo Element, which means I want the same content stored in the combo box and display it right next to the original one. Is there any fast way to copy an element in javascript ?


cheers

Transistor
Nimchi Yung
Ranch Hand

Joined: Jan 27, 2004
Posts: 71
Is there any reason why you can't just do it on the server side?

--Nimchi
YuenLian Wu
Ranch Hand

Joined: Nov 16, 2005
Posts: 73
my form contains a lot of elements, and I wish I can do it at once, just like java, write once, run anywhere
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
might be able to try to clone the node of the select element, not sure if it will copy all of the options. Probbaly the easiest thing is to use createElement with the select and than use new Option() with a for loop.

Eric
matrixy herry
Greenhorn

Joined: Dec 05, 2006
Posts: 2
just do like this,use the method cloneNode() to clone a node and add it to anywhere you want by appendChild()...

<select id="ddddd"><option value="dddd">fasdfd</option></select>
<SCRIPT LANGUAGE="JavaScript">
<!--
var obj = document.getElementById("ddddd").cloneNode(true);
document.body.appendChild(obj);
//-->
</SCRIPT>

[Edit: non-English content removed]
[ December 05, 2006: Message edited by: Bear Bibeault ]
matrixy herry
Greenhorn

Joined: Dec 05, 2006
Posts: 2
[Edit: non-English content removed]
[ December 05, 2006: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Copy Element