TechArena Community

TechArena Community (
-   Software Development (
-   -   Create radio button (

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.

<script Language="JavaScript">
function modify(){
var newe= document.createElement("radio") = "newradio"
document.getElementById("emphasis1").childNodes[0].nodeValue = "first "

Any help or suggestion will be appreciated. Thanks

Zecho 24-11-2009 02:51 PM

Re: Create radio button
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.

newElem.setAttribute("class", "draggable")
Any more problem then do post back.

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

Re: Create radio button
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
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

You have this

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.