Results 1 to 3 of 3

Thread: basic javascript syntax question regarding attributes and functions [SOLVED]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Resolved basic javascript syntax question regarding attributes and functions [SOLVED]

    I'm just starting with javascript. I tinkered this very simple function, that enables / disables two textboxes when a checkbox is clicked.

    VB Code:
    1. <script language="javascript">
    2. <!--
    3. function enableField(tb1, tb2)
    4. {
    5.     with (tb1)
    6.     {
    7.         disabled = !document.form1.checkbox.checked
    8.     }
    9.     with (tb2)
    10.     {
    11.         disabled = !document.form1.checkbox.checked
    12.     }
    13. }
    14. //-->
    15. </script>

    I want to know how can I access the properties of an html object without using the with (attribute) syntax. Basically doing it inline, replacing the name of the object with the attribute I passed to the function.

    Instead of:
    with (tb2)
    {
    disabled = !document.form1.checkbox.checked
    }

    Do:
    document.form1.[attribute I passed].disabled = !document.form1.checkbox.checked

    How can I construct that dynamic path?

    Thank you
    HoraShadow
    Last edited by HoraShadow; Jan 6th, 2006 at 03:02 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width