Link to home
Start Free TrialLog in
Avatar of fyness
fyness

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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);
}
Avatar of fyness
fyness

ASKER


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
yes you should be able to do that... if there are more objects of the same name, the fuction returns an array of objects.
Avatar of fyness

ASKER


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

document.myForm.getElementByName is not a function
Avatar of fyness

ASKER


Got it working!

works with

document.getElementsByName("")

Thanks!