Dynamically disabling form criteria

J

JH

I am doing a questionnaire form. I'm trying to disable a text box
unless a tick box above is ticked. It works with my code below, but if
you select then deselect the box it doesn't then redisable the text box.
Can someone please advise. Also as a secondary issue I believe Service
Pack 2 on XP disables script tags by default thus making this useless?
Is that correct?

<p><font face="Verdana" size="2"><input type="checkbox" name="Q4g"
value="Y"
onMouseOut="javascript:document.myform.q4text.disabled=false">Other
- please state below:-</font></p>
<p><font size="2" face="Verdana"><textarea rows="3" name="q4text"
cols="53" disabled></textarea></font></p>

Thanks JH.
 
P

Philip Ronan

JH said:
I am doing a questionnaire form. I'm trying to disable a text box
unless a tick box above is ticked. It works with my code below, but if
you select then deselect the box it doesn't then redisable the text box.
Can someone please advise. Also as a secondary issue I believe Service
Pack 2 on XP disables script tags by default thus making this useless?
Is that correct?

<p><font face="Verdana" size="2"><input type="checkbox" name="Q4g"
value="Y"
onMouseOut="javascript:document.myform.q4text.disabled=false">Other
- please state below:-</font></p>
<p><font size="2" face="Verdana"><textarea rows="3" name="q4text"
cols="53" disabled></textarea></font></p>

Thanks JH.

Use this:

onchange="document.myform.q4text.disabled = !this.checked"

Don't use onmouseout because it won't work if a visitor uses the keyboard to
change the checkbox. You don't need "javascript:" either.

You should never rely on Javascript being available. Get rid of the
"disabled" attribute in the <textarea> tag, and instead put this in your
<body> tag:

onload="document.myform.q4text.disabled = true"

Phil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top