Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Check Form update not working with Select element

    I have an Update form where I check if any values were changed after someone submits the form.

    If no values changed then message pops up and says:
    You did not update any information for this Form.
    The form will only go to the action page if a value is changed.

    It works great but cant get it to work after I add a validation check on select element.


    Here is my validation check function that I use for onSubmit:
    Code:
    e=myform.elements;
    for (i;i< e.length;i++) 
    {
        if ((e[i].type == 'text') || (e[i].type == 'textarea') || (e[i].type == 'select')) 
        {
           if (e[i].value != e[i].defaultValue) 
           {
              return true;
           }
         }
    }
    alert("You did not update any information for this Form.");
    return false;
    The above checks for text and textarea elements only for changes and wont work with select element.

    My select part of the form:
    Code:
    <form....
    <select name = "myname">
    <option value="a">a</option>
    <option value="b">b</option>
    <option value="c">c</option>
    </select>
    ..
    </form>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Becauase it does not have that property

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Anyway I can add or check select element in my update form using JavaScript?


  •  

    Posting Permissions

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