All pastes #37592 Raw Edit

Miscellany

public javascript v1 · immutable
#37592 ·published 2006-01-20 17:15 UTC
rendered paste body
function copyInputSelect(from,newName){	var inputObj = document.createElement('select');	inputObj.setAttribute('class', from.getAttribute('class'));	inputObj.setAttribute('name', newName);	//loop through the choices	opts = from.options;	for(var i=0; i<opts.length; i++){		var optionObj = document.createElement('option');		optionObj.text = from.options[i].text;		optionObj.value = from.options[i].value;		try{			inputObj.add(optionObj,null); //should work in most browsers that support good dom		} catch(ex) {			inputObj.add(optionObj); //should work in ie, if above fails		}	}		return inputObj;}