Dynamically disabling form criteria

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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"
   - please state below:-</font></p>
   <p><font size="2" face="Verdana"><textarea rows="3" name="q4text"
cols="53" disabled></textarea></font></p>

Thanks JH.

Re: Dynamically disabling form criteria

JH wrote:

Quoted text here. Click to load it

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 [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan /

Site Timeline