0

Hi..
I have a problem with my project.
I want to create dynamic radio button group with different names.

<script language="javascript">
function changeIt()
{

my_div.innerHTML = my_div.innerHTML +"<br>Skills<input type='text' name='mytext[]' value='mytext'>";
my_div.innerHTML = my_div.innerHTML +"<br><input type='radio' id='my' value='mytext' value='male' name='radio[]'>";
my_div.innerHTML = my_div.innerHTML +"<input type='radio' id='my' value='Female' name='radio[]'>";


//var el = document.getElementById('my');
//el.name = 'level';
}
</script>


<form name="form" action="homep.php" method="">

<input type="button" value="test" onClick="changeIt()">
<div id="my_div"></div>
  <input type="submit" name="Submit" value="Submit">


</form>

I want to create a radio button group(2 radio buttons on a group) with different name.
Anybody knows please help me..

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by divyakrishnan
0
<html>

<script language="javascript">
var curr=0 ;
function addradio()
{
    document.getElementById("my_div").innerHTML=document.getElementById("my_div").innerHTML+
"<br><input type='radio' id='my"+curr+"'  value='Male' name='my"+curr+"'>Male "+
"<input type='radio' id='my"+curr+"' value='Female' name='my"+curr+"'>Female ";
  curr=curr+1;
}
function changeIt()
{

my_div.innerHTML = my_div.innerHTML +"<br>Skills<input type='text' name='mytext[]' value='mytext'>";
my_div.innerHTML = my_div.innerHTML +"<br><input type='radio' id='my' value='mytext' value='male' name='radio[]'>";
my_div.innerHTML = my_div.innerHTML +"<input type='radio' id='my' value='Female' name='radio[]'>";


//var el = document.getElementById('my');
//el.name = 'level';
}
</script>

<body>
<form name="form" action="homep.php" method="">

<input type="button" value="test" onClick="addradio()">
<div id="my_div"></div>
  <input type="submit" name="Submit" value="Submit">



</form>
</body>
</html>

Edited by urtrivedi: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.