Using JavaScript to shade form fields

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike N.

    Using JavaScript to shade form fields

    I am looking to use an HTML checkbox feature as a trigger to
    shade/unshade a multiple select field in an HTML form. For instance:
    there are four options in the multiple select field and one outside of
    it. Is there a simple way, using JavaScript, so that if the outside
    option is selected, or "checked", the multiple select field will be
    shaded (unusable) and if it's deselected, or "unchecked" , the multiple
    select field will be unshaded (usable)? Also, if the outside field is
    checked, it's value should be written upon submittal.

    Thanks in advance!
  • Greg Griffiths

    #2
    Re: Using JavaScript to shade form fields

    You'll probably have to do this with CSS as well as Javascript. check out

    "Mike N." wrote:
    [color=blue]
    > I am looking to use an HTML checkbox feature as a trigger to
    > shade/unshade a multiple select field in an HTML form. For instance:
    > there are four options in the multiple select field and one outside of
    > it. Is there a simple way, using JavaScript, so that if the outside
    > option is selected, or "checked", the multiple select field will be
    > shaded (unusable) and if it's deselected, or "unchecked" , the multiple
    > select field will be unshaded (usable)? Also, if the outside field is
    > checked, it's value should be written upon submittal.
    >
    > Thanks in advance![/color]

    Comment

    • Mike N.

      #3
      Re: Using JavaScript to shade form fields

      I received the following in an e-mail. This code worked perfectly.

      ------------------------------------------------------------

      Hi Mike,
      You need to use "form.object.di sabled=true/false"
      I've written all the code you need below.

      Best wishes

      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

      <script language="JavaS cript" type="text/javascript">
      function shade(){
      if(document.tes tform.status.ch ecked==true){do cument.testform .content.disabl e
      d=true}
      else{document.t estform.content .disabled=false }
      }
      </script>

      </head>
      <body>
      I think what you're looking for is "form.object.di sabled=true/false"<br><br>


      <form name="testform" >
      <input type="checkbox" name="status" checked onClick="shade( )">Disabled
      when checked<br>
      <input type="text" name="content" size="40" value="Disabled - UnCheck to
      Enable" maxlength="40" disabled>
      </form>


      (Mike N.) wrote in message news:<17990171. 0404221013.41be 5065@posting.go ogle.com>...[color=blue]
      > I am looking to use an HTML checkbox feature as a trigger to
      > shade/unshade a multiple select field in an HTML form. For instance:
      > there are four options in the multiple select field and one outside of
      > it. Is there a simple way, using JavaScript, so that if the outside
      > option is selected, or "checked", the multiple select field will be
      > shaded (unusable) and if it's deselected, or "unchecked" , the multiple
      > select field will be unshaded (usable)? Also, if the outside field is
      > checked, it's value should be written upon submittal.
      >
      > Thanks in advance![/color]

      Comment

      Working...