SitePoint Sponsor

User Tag List

Results 1 to 1 of 1

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Enable/Disable Form Fields Script

    Hello, I am new to javascript.

    I found a script that disable form fields by checking or unchecking a checkbox... however I would like it to do it backwards, that is... enable disabled fields... I have no clue on how to accomplish this.

    Maybe some one knows how to modify it:

    Code:
    <head>
    <script type="text/javascript">
    function toggle(){
    var i, j, args, els;
    args=toggle.arguments
    els=document.forms[args[0]]
    i=0
    while (typeof(els[i])!=='undefined'){
    for (j = 1; j < args.length-1; j++)
    if(els[i].name==args[j])
    els[i].disabled=args[args.length-1]
    i++
    }
    }
    </script>
    </head>
    <body>
    <form name="myForm">
      <p>
      <input type="checkbox" name="solution_needs" value="oppid" onclick="toggle('myForm', 'fname', 'lname', 'company', 'select', 'textfield', this.checked)">
      <br>
      <INPUT NAME="fname" SIZE="30" TYPE="text">
      <br>
      <INPUT NAME="lname" SIZE="30" TYPE="text">
      <br>
      <INPUT NAME="company" SIZE="30" TYPE="text">
      <br>
      <select name="select">
      </select>
      </p>
      <p>
        <textarea name="textfield" rows="3"></textarea>
        </p>
    </form>
    </body>
    Thanks a lot
    Last edited by raml; May 24, 2007 at 19:14.


Bookmarks

Posting Permissions

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