1 Reply Latest reply on Aug 13, 2006 11:25 AM by Newsgroup_User

    PHP Form...

    Level 7
      Hey gang,

      I have a quote form in which I'm using Javascript to show/hide fields
      depending upon which radio button is selected (e.g., "Yes" or "No").

      Basically, this bit is in the Javascript file that will automatically "hide"
      all of the show/hide fields when the page loads - this way, if Javascript is
      disabled - the user isn't hindered - all fields display:

      function hideOnLoad() //hides listed divs on body load. This is to allow all
      divs to show if JS is turned off.
      {
      changeDiv("currentdomain","none");
      changeDiv("completedate","none");
      }

      Okay - and this is how I'm showing/hiding the optional fields contained in
      either the "currentdomain" div ID or in the "completedate" div ID.

      For "No":
      onclick="changeDiv('currentdomain','none');"

      For "Yes":
      onclick="changeDiv('currentdomain','block');"

      Now, my problem is that when the user submits the form - if there is
      mistakes, all the optional fields they filled out if they selected "Yes" -
      are hidden by the hideOnLoad function.

      How can I tell this to only "hide" them if it's the first time the page has
      loaded, or something to that matter.

      And by-the-way the Javascript function is in an external Javascript (.js)
      file.

      If you need a page to reference, here is the mock page I've been working
      with it on:

      http://www.avenuedesigners.com/quote_mess.php

      There are only two places this is being used, both "Yes" or "No" radio
      button questions.

      Thank you!

      --
      Shane H
      shane@NOSPAMavenuedesigners.com
      http://www.avenuedesigners.com

      =============================================
      Proud GAWDS Member
      http://www.gawds.org/showmember.php?memberid=1495

      Delivering accessible websites to all ...
      =============================================



        • 1. Re: PHP Form...
          Level 7
          SOLVED by myself:

          <?php
          echo '<script type="text/javascript">';
          echo 'function hideOnLoad() {';
          if(isset($_POST['sent'])) {
          if($_POST['havewebsite'] == "yes") {
          echo 'changeDiv("currentdomain","block");';
          }
          else {
          echo 'changeDiv("currentdomain","none");';
          }
          if($_POST['dateyesno'] == "yes") {
          echo 'changeDiv("completedate","block");';
          }
          else {
          echo 'changeDiv("completedate","none");';
          }
          }
          else {
          echo 'changeDiv("currentdomain","none");';
          echo 'changeDiv("completedate","none");';
          }
          echo '}';
          echo '</script>';
          ?>


          --
          Shane H
          shane@NOSPAMavenuedesigners.com
          http://www.avenuedesigners.com

          =============================================
          Proud GAWDS Member
          http://www.gawds.org/showmember.php?memberid=1495

          Delivering accessible websites to all ...
          =============================================


          "Shane H" <shane@NOSPAMavenuedesigners.com> wrote in message
          news:ebmd57$oug$1@forums.macromedia.com...
          > Hey gang,
          >
          > I have a quote form in which I'm using Javascript to show/hide fields
          > depending upon which radio button is selected (e.g., "Yes" or "No").
          >
          > Basically, this bit is in the Javascript file that will automatically
          > "hide" all of the show/hide fields when the page loads - this way, if
          > Javascript is disabled - the user isn't hindered - all fields display:
          >
          > function hideOnLoad() //hides listed divs on body load. This is to allow
          > all divs to show if JS is turned off.
          > {
          > changeDiv("currentdomain","none");
          > changeDiv("completedate","none");
          > }
          >
          > Okay - and this is how I'm showing/hiding the optional fields contained in
          > either the "currentdomain" div ID or in the "completedate" div ID.
          >
          > For "No":
          > onclick="changeDiv('currentdomain','none');"
          >
          > For "Yes":
          > onclick="changeDiv('currentdomain','block');"
          >
          > Now, my problem is that when the user submits the form - if there is
          > mistakes, all the optional fields they filled out if they selected "Yes" -
          > are hidden by the hideOnLoad function.
          >
          > How can I tell this to only "hide" them if it's the first time the page
          > has loaded, or something to that matter.
          >
          > And by-the-way the Javascript function is in an external Javascript (.js)
          > file.
          >
          > If you need a page to reference, here is the mock page I've been working
          > with it on:
          >
          > http://www.avenuedesigners.com/quote_mess.php
          >
          > There are only two places this is being used, both "Yes" or "No" radio
          > button questions.
          >
          > Thank you!
          >
          > --
          > Shane H
          > shane@NOSPAMavenuedesigners.com
          > http://www.avenuedesigners.com
          >
          > =============================================
          > Proud GAWDS Member
          > http://www.gawds.org/showmember.php?memberid=1495
          >
          > Delivering accessible websites to all ...
          > =============================================
          >
          >
          >