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. Advertisements

  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. Advertisements

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. Jason Galvin

    Disabling auto-populating of form elements

    Jason Galvin, Dec 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    438
    Teemu Keiski
    Dec 10, 2003
  2. Lamine Darbouche
    Replies:
    1
    Views:
    549
    Johannes Hammersen
    Jun 29, 2005
  3. Assimalyst
    Replies:
    3
    Views:
    2,049
    Assimalyst
    Aug 9, 2005
  4. Replies:
    1
    Views:
    363
    John Timney \(MVP\)
    Mar 17, 2007
  5. jm
    Replies:
    3
    Views:
    329
  6. dougloj

    Disabling buttons when a form is submitted

    dougloj, Feb 24, 2006, in forum: ASP .Net Security
    Replies:
    1
    Views:
    184
  7. Micromanaged

    Form change based upon criteria selected?

    Micromanaged, Jul 2, 2004, in forum: ASP General
    Replies:
    3
    Views:
    270
    Bullschmidt
    Jul 5, 2004
  8. Replies:
    2
    Views:
    217
Loading...