PDA

View Full Version : onlick disable textbox is not already diabled


brooky
04-05-2007, 12:15 PM
Hello,

I've created the following code but I can't understand why it won't work.

findObj was created by Dreamweaver which is basically a better solution that find object by id:

function toggleReg()
{
if(findObj('password').disabled=false && findObj('passwordConf').disabled=false)
{
findObj('password').disabled=true;
findObj('passwordConf').disabled=true;
}
else
{
findObj('password').disabled=false;
findObj('passwordConf').disabled=false;
}
}

<tr>
<td colspan="4">I do not want to create an account
<input type="checkbox" name="account" value="1" onclick="toggleReg();" /></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="password" class="textbox" id="password" size="16" value="" tabindex="13" /> * </td>
<td>Confirm Password</td>
<td><input name="passwordConf" type="password" class="textbox" id="passwordConf" size="16" value="" tabindex="14" />
* </td>
</tr>

Can anyone see why it won't work? I'm a fairly competent coder but useless with JavaScript.

Mr J
04-05-2007, 05:35 PM
You are assigning instead of comparing

if(findObj('password').disabled=false && findObj('passwordConf').disabled=false)

should be

if(findObj('password').disabled==false && findObj('passwordConf').disabled==false)

brooky
04-06-2007, 04:20 AM
God I should have known better!! Thanks! :)