View Full Version : Copy Select With Same Options

02-21-2005, 05:43 AM

I've been playing around with the following code for days already and still in the dark tunnel.

Can someone tell me what's wrong with the way I've coded it?

var cell1 = row.insertCell(0);
var selOpt = document.createElement('input');
selOpt.setAttribute('type', 'select');
selOpt.option = document.forms[0].Country.option;
selOpt.setAttribute('name', 'AnotherCtry');

<edit>What I'm trying to do is to copy the options of the Country to another select which I've allowed the users to 'add' to the current row.</edit>

02-21-2005, 06:02 AM
Well, select is it's own element, it is not just a type of input element.

02-21-2005, 09:11 AM
Ok, so how should I code it such that I can have duplicates of the options in a new select?

02-21-2005, 09:45 AM
Well, I would use a cloneNode (http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-3A0ED0A4) for that.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum