A
ankitvermamca
I'm trying to dynamically add radio inputs to a form, but it's not
working quite right. The code I have adds the radio buttons properly,
but they are not selectable, and I can't seem to be able to retrieve
the value. How do I fix it so they are selectable, and I can retrieve
the value of the one the user selects?
It only needs to work on IE5 or higher. Thanks in advance.
Dex*
---
Here is the code thus far
---
<!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("<input
type=\"radio\">");
//aE2.Type = "radio";
aE2.Name = "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()
{
var str = "Options Created = " + nCount + "\n" +
"Selected = " +
frmTest.SelOpt.value;
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>
working quite right. The code I have adds the radio buttons properly,
but they are not selectable, and I can't seem to be able to retrieve
the value. How do I fix it so they are selectable, and I can retrieve
the value of the one the user selects?
It only needs to work on IE5 or higher. Thanks in advance.
Dex*
---
Here is the code thus far
---
<!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("<input
type=\"radio\">");
//aE2.Type = "radio";
aE2.Name = "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()
{
var str = "Options Created = " + nCount + "\n" +
"Selected = " +
frmTest.SelOpt.value;
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>