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..

<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>

Hey....Thank u for your help.Now my problem is fixed.I can run the script..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.