Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use HTML field name in javascript if the field name contains a "." (dot)?

I am using <detail:form> and <tags:field > in my jsp page. I tried to see the source code the browser generates using firebug and it showed to me that the form name is "checkForm" and all of the field names has "check." as a prefix. So one of the field's (it is a radio button) name is check.isEndorseByApplicant .

What I am trying to achieve is, when a some element in a drop down menu is selected, I wanted to change the radio button from yes to no. The problem is since the field contains dot in its name, I can't do that. i.e document.checkForm.check.isEndorseByApplicant is not working for me. There is no way I can take out the dot from the field's name at this time. Any ideas?

            function autoSelect(checkEndorsement)
            {
            alert(document.checkForm.check.isEndorseByApplicant)
                if(checkEndorsement.value=="Student")
                    check.isEndorsedBy[0].checked=true;
                else
                    check.isEndorsedBy[1].checked=true;
            }


        </html:javascript>

. . .

<detail:form object="check" >

. . . .

<td><tags:field property="isEndorseByApplicant" onclick="autoSelect(this.form);"  /></td>
like image 668
WowBow Avatar asked Apr 27 '12 14:04

WowBow


1 Answers

Use document.checkForm.elements['check.isEndorseByApplicant']

like image 104
phantasm Avatar answered Oct 26 '22 07:10

phantasm