www.webdeveloper.com
Results 1 to 5 of 5

Thread: Form controls manipulation

  1. #1
    Join Date
    Nov 2003
    Posts
    39

    Angry Form controls manipulation

    hi, pls i need help. i have an html page containing some Form controls but am also generating and naming some controls e.g Checkbox and Textbox dynamically using a server side script, the naming of the controls(Form) is base on the fields name from my table in my database, now there's my problem. How do i check if a control generated dynamically e.g Checkbox is checked or not by the user using javascript.

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    ...
    if(document.forms['formname'].elements['checkboxname'].checked){
    ...
    }

    checked is a form's element checkbox attribute
    values are booloean true/false
    the default (obj.checked) value is true

  3. #3
    Join Date
    Nov 2003
    Posts
    39
    But can i put dynamic varables into this ['checkboxname'] since am generating the name dynamically?

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    it does not matter wether names are set up as a HTML static code or are dynamically generated. The condition is that those checkboxes to have a unique name

    <input name="blabla0" type="checkbox">
    <input name="blabla1" type="checkbox">
    ..

    If you use an incremental type name (blablai), you may later simplify the code using a for loop.

    You may also use the order of elemets, not necessarily the name, as the general reference is

    document.forms[name_or_order].elements[name_or_order].attribute

    In this case you have to build first an array with the elements who have the same type (type="checkbox" in your case)

  5. #5
    Join Date
    Nov 2003
    Posts
    39
    thanx alot Kor

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles