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

1

6

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>
Steading answered 27/4, 2012 at 14:35 Comment(0)
M
5

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

Majuscule answered 27/4, 2012 at 14:38 Comment(1)
That's awesome. Many thanks. Btw, that's why I love stackoverflow. :PSteading

© 2022 - 2024 — McMap. All rights reserved.