I am trying to use some javasript to control the locking/unlocking of a textbox that is populated with data from our AD.
This is an example of the code:
Response.Write "<tr><td><input type=checkbox name='chkext' onclick=""this.form.txtext.disabled=false"" /> Phone Extension: <input type=text name='txtext' Disabled='true' value='" & oRecordSet.Fields("telephonenumber") & "' /></td></tr>"
Now everything works. When the user checks the box the textbox becomes editable. The problem is that when they uncheck the box the field stays editable. Ideally I would like it to lock.
I am guessing I need some sort of Javascript function but this is where I run into trouble.
Heres what I am kind of thinking the function would need to be.
function lockfields()
{
if (this.form.txtfName.disabled=false)
{
this.form.txtfName.disabled=True;
}
if (this.form.txtfName.disabled=True)
{
this.form.txtfName.disabled=False;
}
}
I was just playing around, obviously txtfname needs to be a variable and the function needs to get the variable value when the checkbox is checked or unchecked.
Question
Sophism
I am coding a form using ASP.
I am trying to use some javasript to control the locking/unlocking of a textbox that is populated with data from our AD.
This is an example of the code:
Response.Write "<tr><td><input type=checkbox name='chkext' onclick=""this.form.txtext.disabled=false"" /> Phone Extension: <input type=text name='txtext' Disabled='true' value='" & oRecordSet.Fields("telephonenumber") & "' /></td></tr>"Now everything works. When the user checks the box the textbox becomes editable. The problem is that when they uncheck the box the field stays editable. Ideally I would like it to lock.
I am guessing I need some sort of Javascript function but this is where I run into trouble.
Heres what I am kind of thinking the function would need to be.
function lockfields() { if (this.form.txtfName.disabled=false) { this.form.txtfName.disabled=True; } if (this.form.txtfName.disabled=True) { this.form.txtfName.disabled=False; } }I was just playing around, obviously txtfname needs to be a variable and the function needs to get the variable value when the checkbox is checked or unchecked.
Link to comment
Share on other sites
1 answer to this question
Recommended Posts