Dynamically disabling form criteria

Discussion in 'HTML' started by JH, Dec 9, 2004.

  1. JH

    JH Guest

    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.
     
    JH, Dec 9, 2004
    #1
    1. Advertising

  2. JH

    Philip Ronan Guest

    JH wrote:

    > 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

    --
    phil [dot] ronan @ virgin [dot] net
    http://vzone.virgin.net/phil.ronan/
     
    Philip Ronan, Dec 10, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephajn Craig

    Highlight Text based on certain criteria

    Stephajn Craig, Jul 7, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    386
    Axel Dahmen
    Jul 8, 2003
  2. VM
    Replies:
    12
    Views:
    589
    .NETgeek
    Feb 29, 2004
  3. jm
    Replies:
    3
    Views:
    255
  4. Micromanaged

    Form change based upon criteria selected?

    Micromanaged, Jul 2, 2004, in forum: ASP General
    Replies:
    3
    Views:
    142
    Bullschmidt
    Jul 5, 2004
  5. Replies:
    2
    Views:
    144
Loading...

Share This Page