473,508 Members | 2,206 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to function Radio Button & Add Text Area in JS

13 New Member
Hello,

I am trying to add 2 RadioButtons in a form in js dynamically. I can see 2 radiobutttons, but no text. On clicking them, their is no selection. One of them is selected. I need to retrive their vakue on button click. The form is added in a div which is present in html form (that is not dynamically created). Form & all other elements are created dynamically & appended to div elemetn whch is present in html. The code is :

Expand|Select|Wrap|Line Numbers
  1.  
  2.     var miles=document.createElement("input");
  3.     miles.setAttribute("type", "radio");
  4.     miles.setAttribute("id", "miles");
  5.     miles.setAttribute("value", "miles");
  6.     miles.setAttribute("checked", "true");
  7.     miles.setAttribute("name", "units");
  8.  
  9.     var km=document.createElement("input");
  10.     km.setAttribute("type", "radio");
  11.     km.setAttribute("id", "km");
  12.     km.setAttribute("value", "km");
  13.     km.setAttribute("checked", "false");
  14.     km.setAttribute("name", "units");
  15.  
  16.     var getVal=function(){
  17.         scaleUnits=document.forms['dynamicForm'].elements['radio'].value;
  18.         alert(scaleUnits);
  19.         driveFrom=document.forms['dynamicForm'].elements['fromTxt'].value;
  20.         driveTo=document.forms['dynamicForm'].elements['toTxt'].value; 
  21.         GetDirections(driveFrom, driveTo);
  22.     }  //this sets up a function in the same scope as the onclick assignment that will use it.
  23.     getDirectionsBtn.onclick=getVal;  //this assigns the function to the element.
  24.  
Regarding TExt Area:-
Based on the above form, I want to add a TextArea via another function. The code is :-
Expand|Select|Wrap|Line Numbers
  1. function DoAlert(text) {
  2.     var d=document.getElementById("directDIV");
  3.     var e=document.getElementById("dynamicForm");
  4.     d.style.visibility="visible";
  5. //     var dynamicForm=document.createElement("form");
  6. //    dynamicForm.setAttribute("id", "dynamicForm");
  7. //    dynamicForm.setAttribute("runat", "server");
  8.  
  9.     var textTA=document.createElement("textarea");
  10.     textTA.setAttribute("id", "textTA");
  11.     textTA.setAttribute("overflow", "auto");
  12.     textTA.setAttribute("rows", "30");
  13.     textTA.innerHTML=text;
  14.  
  15.     e.appendChild(textTA);
  16. //    d.insertBefore(dynamicForm, lbl);    
  17. }
This gives me error on textTA.innerHTML line. If this is incorrect, then how do i add contents to the text area.

Help me guys.

Thank

Trupti
May 12 '07 #1
1 1942
pbmods
5,821 Recognized Expert Expert
This gives me error on textTA.innerHTML line. If this is incorrect, then how do i add contents to the text area.
Expand|Select|Wrap|Line Numbers
  1. textTA.value = text;
  2.  
May 12 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2289
by: Arun Nair | last post by:
Hi, I have the following jsp page. I am able to view only a part of it(until the occurence of the first City text box). If i remove the first few fields from the page, I am able to see a few...
1
3416
by: Dave | last post by:
Hi, there used to be a simple javascript quiz builder in builder.com, with which I made the page whose code is given below. I would like to tweak this so that there are only three (not 4) answer...
4
27560
by: Gaurav | last post by:
hello, I have a form where i have a number of radio buttons. How can i change space between the radio button and its text example o first radio button o second radio button
2
12325
by: jason | last post by:
The following (likely far from imperfect code), reports a value of NaN in the j4 display. I suppose the problem is I am not really passing the "checked" value of the radio button via .value ......
4
3251
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
2
2291
by: xazos79 | last post by:
Hi All, I've come across the problem of not being able to re-enable a radio button with javascript if its initial state has been disabled in the Page_Load() method of the code behind. Might i...
4
2897
by: poojak | last post by:
I have write two different js function in a external file. one function write a table (I used innerHTML for this.) and another function is for showing/ hideing some rows depending on radio button...
1
2797
by: runway27 | last post by:
hi i have registration form where user selects from a drop down to select their area code apart from filling other details in the form. in the next page which is a confirmation page i would like...
2
2799
by: runway27 | last post by:
i am using a self submitting form <form action="<?php echo $_SERVER; ?>" method="POST" id="test2" name="test1"> i need to do a validation of textfields, checkboxes, radio buttons i am able...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.