Forum Moderators: open

Message Too Old, No Replies

New to Javascript - Trouble Changing Form Field Properties

         

radiator251

8:32 pm on Oct 8, 2009 (gmt 0)

10+ Year Member



I thought I had a handle on javascript, but apparently not. I have a form for editing a profile, in which the fields are disabled until the user clicks the corresponding "edit" button next to them. However, the onClick code I have for the buttons doesn't seem to be working. I click on the button but it doesn't change the state of the text field. Here's the relevant code:

<form action="/handlers/profile_edit_post.php" method="post" enctype="multipart/form-data" name="profile">
<?php echo $_SESSION['USER_USERNAME']; ?><br /><br />
<label>E-mail:</label><input class="form-input-field" type="text" value="<?php echo GetUserEmail($_SESSION['USER_ID']); ?>" name="email" size="40" DISABLED/> <input type="button" value="Edit" onClick="document.profile.email.disabled=FALSE;"/>

Any help would be appreciated. Thanks.

daveVk

11:51 am on Oct 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try
this.form.getElementsByName('email')[0]
in place of
document.profile.email

Fotiman

12:48 pm on Oct 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



JavaScript is a case sensitive language, and the boolean values are true and false (all lower case). Try this:
onClick="document.profile.email.disabled=false;"