Calliphoridae (pkbarbiedoll) wrote in javascript,
Calliphoridae
pkbarbiedoll
javascript

Javascript variable names & arrays (variable variables?)

I wrote a function to select one of an array of checkboxes. The form name, checkbox name, and value to be checked is passed. If I hardcode the form name, it works great. I want to make the function flexible to reuse in other situations, so the form name needs to be a variable.

EDITED - problem solved. If anyone needs this feel free to use or improve.

Scope:
Will toggle checkbox matching a certain value in an array of checkboxes. Similar to the "select all" but it just selects one. It's designed to be invoked with onClick from the checkbox description. See below....

Javascript:


Usage:
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 4 comments