-
Create radio button
Hi friends
I wrote a program that has a button on it, when I press that button the scripts activates and creates new radio buttons. The problems is that I want the radio button to be of the class draggable. I have posted my code below.
Code:
<script Language="JavaScript">
function modify(){
var newe= document.createElement("radio")
newe.id = "newradio"
newe.appendChild(newe)
document.body.appendChild(newe)
document.getElementById("emphasis1").childNodes[0].nodeValue = "first "
}
</script>
Any help or suggestion will be appreciated. Thanks
-
Re: Create radio button
Hello
If you are talking about the CSS class. Then setAttribute should work fine with your problem. I have posted the part of the code, I have not tested it. but it may help you.
Code:
newElem.setAttribute("class", "draggable")
Any more problem then do post back.
-
Re: Create radio button
Hi
Thanks for the reply. That works fine without any errors. But sorry it still does not display a radio button on the page. I am not that experienced to javascript and any advice is appreciated. Please help
-
Re: Create radio button
Hi
I think you have to append it to the DOM when you have done creating it. I feel that the input element which you need will be in the form. It will be good rather than adding it to the body element. See the statement below
Code:
document.forms[0].appChild(newElem);
You have this
Code:
newElem.appChild(newElem)
But I am not sure what will happen when you add an element to itself. Still you try it and any query post back. Even if you have solved it do post back with the solution.
Page generated in 1,714,024,129.71530 seconds with 11 queries