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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Location
    Seattle, WA
    Posts
    116
    Thanks
    1
    Thanked 0 Times in 0 Posts

    changing form values with onChange

    I'm having a hard time changing the value of a hidden form element with the onChange event handler. The form pretty much looks like this:

    <form action="redirect.php" method="post" name="admin">
    <input type="hidden" name="purpose" value="update_users">
    <input type="hidden" name="0-id" value="1">
    <input type="hidden" name="0-changed_pass">
    <input type="text" name="0-user" value="jseay"></td>
    <input type="password" name="0-pass" value="passwerd" onChange="document.admin.0-changed_pass.value='changed'">
    <input type="checkbox" name="0-u_admin" value="y" checked>
    <input type="checkbox" name="0-s_admin" value="y" checked>
    <input type="checkbox" name="0-n_admin" value="y" checked>
    ....
    </form>
    And when I submit the form, if the 0-pass value has been changed, it doesn't seem to effect the value of the hidden element 0-changed_pass. Any idea why that would be? Thanks.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    I changed 2 things, the 0 (zero) to a letter o and the minus - to an underscore_

    You had

    onChange="document.admin.0-changed_pass.value='changed'"

    which would read,

    onchange document.admin.0 minus changed_pass.value equals changed

    The zero effects as well

    Please try the following


    form action="redirect.php" method="post" name="admin">
    <input type="hidden" name="purpose" value="update_users">
    <input type="hidden" name="o_id" value="1">
    <input type="hidden" name="o_changed_pass">
    <input type="text" name="o_user" value="jseay"></td>
    <input type="password" name="o_pass" value="password" onChange="document.admin.o_changed_pass.value='changed'">
    <input type="checkbox" name="o_u_admin" value="y" checked>
    <input type="checkbox" name="o_s_admin" value="y" checked>
    <input type="checkbox" name="o_n_admin" value="y" checked>
    </form>

  • #3
    Regular Coder
    Join Date
    Dec 2002
    Location
    Seattle, WA
    Posts
    116
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Well I need the zero for counting purposes on the next script but I did change all the hyphens to underscores in the elemt names but it still doesn't respond. I mean for the most part it works fine, but the value of that hidden form element never does get changed regardless of how many times I change the password field.

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Did you try it as I posted it before you changed the o's back to zeros

  • #5
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Could you not do something like this

    <form action="redirect.php" method="post" name="admin">
    <input type="hidden" name="purpose" value="update_users">
    <input type="hidden" name="_0_id" value="1">
    <input type="hidden" name="_0_changed_pass">
    <input type="text" name="_0_user" value="jseay"></td>
    <input type="password" name="_0_pass" value="password" onChange="document.admin._0_changed_pass.value='changed'">
    <input type="checkbox" name="_0_u_admin" value="y" checked>
    <input type="checkbox" name="_0_s_admin" value="y" checked>
    <input type="checkbox" name="_0_n_admin" value="y" checked>
    </form>



    Use the link to check

    <a href="#null" onclick="alert('_0_changed_pass value\n\n=\n\n'+admin._0_changed_pass.value)">CLICK</a>
    Last edited by Mr J; 06-08-2003 at 07:11 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
    •