简体   繁体   中英

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. ie 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>

使用document.checkForm.elements['check.isEndorseByApplicant']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM