[Javascript] Re: access form.element by name containing [ ]

Rodney Myers rodney at aflyingstart.net
Wed Sep 19 13:09:46 CDT 2001


<form name="grants">
<table width="400">
  <tr>
    <td>Intern</td>
    <td><input type="checkbox" name="grants[intern_read]" checked> Read
</td>
  </tr>
  <tr>
    <td>Extern</td>
    <td><input type="checkbox" name="grants[extern_close]"> Close </td>
  </tr>
</table>

<a class="small" href="#"
onclick="window.document.grants['grants[intern_read]'].checked=true;
window.document.grants['grants[extern_close]'].checked=false;">
  Default-Rechte setzen</a>
</table>
</form>


Notes:
Form name="grants"  given and object defined in link as
window.document.grants
checked attribute should not be checked="on"

href to this javascript results in page displaying the word false, so using
onclick.
and href="#"
I don't use that combination much. Others may have useful comments

Rodney

Patrick Bierans wrote:

> Thanks a lot!

> It worked great for buttons. But on checkboxes...
> weired. May you have a look?
>
> Isn't the link object owned by document?
>
> <form>
> <table width="400">
>   <tr>
>     <td>Intern</td>
>     <td><input type="checkbox" name="grants[intern_read]"
> checked="on"> Read </td>
>   </tr>
>   <tr>
>     <td>Extern</td>
>     <td><input type="checkbox" name="grants[extern_close]"> Close </td>
>   </tr>
> </table>
>
> <a class="small" href="javascript:
>   this.form['grants[intern_read]'].checked=true;
>   this.form['grants[extern_close]'].checked=false;">
>   Default-Rechte setzen</a>
> </form>
>
> --
> Patrick Bierans / LYNET Kommunikation AG / pbierans at lynet.de
> -----------------------------------------------------------------------
> Das Internet-Systemhaus fuer Multimedia- und Netzwerkloesungen.
> Zentrale Luebeck: Fon +49-451-6131-0, Fax -333
> Niederlassung Hamburg:  Fon +49-40-65738-0, Fax -333

--
Shop at ssistant Add-ons and Developer Workshops
http://www.aflyingstart.net/addons/

Enquiries regarding Shop at ssistant Classic training :
Call 01256 880770

Rodney Myers
Based in Oxford, England
Technical Director, Shop at ssistant eCommerce Solutions





More information about the Javascript mailing list