Thanks, Zvonko! That is an improvement.
Couple of issues remain:
1) Why do I have to specify the name in the createElement command? Why doesn't it work to set it after the fact? (The same is true for the type="radio" part. I should be able to say aE2.type = "radio" but that doesn't work either.
2) It doesn't report what the value of the selected control was. It just says whether or not one was selected. I am going to need the value. For now, it just fills the div with something like:
Options Created = 3 Selected = on
Thanks.
Dex*
Main Topics
Browse All Topics





by: ZvonkoPosted on 2004-04-08 at 12:55:22ID: 10786653
Check this:
nput type=\"radio\" name=\"SelOpt\" >");
i++){ ue){ {
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Radio Test</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-1">
<SCRIPT>
var nCount = 0;
function AddRadio()
{
var aE2 = document.createElement("<i
//aE2.type = "radio";
//aE2.name = "SelOpt";
aE2.id = "SelOpt";
aE2.value = ++nCount;
var oRow = tblTest.insertRow(-1);
var oCell = oRow.insertCell(-1);
oCell.appendChild( aE2 );
oCell = oRow.insertCell(-1);
oCell.innerHTML = "Option #" + nCount;
}
function RadioTest()
{
selOptVal = "undefined";
selGroup = frmTest.SelOpt;
if(selGroup.length){
for(i=0;i<selGroup.length;
if(selGroup[i].checked==tr
selOptVal = selGroup[i].value;
}
}
} else {
if(selGroup.checked==true)
selOptVal = selGroup.value;
}
}
var str = "Options Created = " + nCount + "\n" +
"Selected = " + selOptVal;
divResult.innerHTML = str;
}
</SCRIPT>
</HEAD>
<BODY>
<BLOCKQUOTE>
<h1>Radio Test</h1>
<input type=button onclick="AddRadio();" value="Add Radio Option">
<br>
<input type=button onclick="RadioTest();" value="Show Option" ID="Button1" NAME="Button1">
<p>
<div id="divResult"></div>
</p>
<form id="frmTest">
<table id="tblTest">
</table>
</form>
</BLOCKQUOTE>
</BODY>
</HTML>