Forms and Javascript


Hi Experts,

I have an options form on a JSP that consist of multiple radio buttons, i'm trying to use javascript and i'm having trouble finding the property because the form uses transfer beans if name a property

<html:radio proptery="mytransferbean.getFormAttrubite" value="true" onClick=callJavaScript/>

 as opposed to putting all the form attributes in the form directly

<html:radio proptery="getFromAttrubite" value="true" onClick=callJavaScript/>

My javascript doesnt like nested names so

document.myForm.mytransferbean.getFormAttrubute

isnt found

Any ideas on  how to solve this problem????  I've tried using

document.myForm.element[1] etc but because the form is quite large its to many elements to manage.

Thanks!
Fynzy
fynessAsked:
Who is Participating?
 
KuldeepchaturvediConnect With a Mentor Commented:
gerElementByName("mytransferbean.getFormAttrubite");
0
 
Weiping DuSenior Web DeveloperCommented:
You could directly pass radio object to Javascript function .
<html:radio proptery="mytransferbean.getFormAttrubite" value="true"  onClick="callJavaScript( this )"/>

function callJavaScript (obj) {
    alert(obj.value);
}
0
 
fynessAuthor Commented:

if i use getElementByName("")  if i have 2 properties the same, both radio buttons can i call each one as normal

document.getForm.getAttrubiteRadio[0]
document.getForm.getAttrubiteRadio[1]

Thanks,
Suzy
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
KuldeepchaturvediCommented:
yes you should be able to do that... if there are more objects of the same name, the fuction returns an array of objects.
0
 
fynessAuthor Commented:

when i use getElementByName i get the following javascript error in firefox

document.myForm.getElementByName is not a function
0
 
fynessAuthor Commented:

Got it working!

works with

document.getElementsByName("")

Thanks!
0
All Courses

From novice to tech pro — start learning today.