TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   Create radio button (http://forums.techarena.in/software-development/1274557.htm)

Linux-Us 24-11-2009 02:48 PM

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

Zecho 24-11-2009 02:51 PM

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.

Linux-Us 24-11-2009 02:54 PM

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

Zecho 24-11-2009 02:58 PM

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.


All times are GMT +5.5. The time now is 10:04 AM.