Not sure of what you realy want, you can optimize this and use;
Code:
<html>
<head>
function radioDisp(){
var radio1=document.form1.radio1,
radio2=document.form1.radio2,
//create select box and add name attribute
sel=document.createElement('select');
sel.setAttribute('name','myselect');
sel.style.width = "100px";
//append it to form1
document.form1.appendChild(sel);
// evt function to add click event to each
//of the radio buttons
function evt(rad){
if(!rad){
return false;
}
var radLen=rad.length;
while(radLen--){
rad[radLen].onclick=function(){
var radVal=this.value;
var option=document.createElement('option');
sel.appendChild(option);
option.value=radVal;
option.innerHTML=radVal;
}
}
}
// call evt with reference to each set of radio
//elements
evt(radio1);
evt(radio2);
}
</script>
</head>
<body onload="radioDisp()">
<h1>New Web Project Page</h1>
<form name="form1">
<input type="radio" name="radio1" value="one" /> One<br />
<input type="radio" name="radio1" value="two" /> Two<br />
<input type="radio" name="radio1" value="three" /> Three<br />
<input type="radio" name="radio2" value="Bart" /> Bart<br />
<input type="radio" name="radio2" value="Lisa" /> Lisa<br />
<input type="radio" name="radio2" value="Marge" /> Marge<br />
</form>
</body>
</html>
Bookmarks