Announcement

Collapse
No announcement yet.

Show/Hide new customer password boxes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Show/Hide new customer password boxes

    Hi All

    I have been trying, with little success, to hide the new customer password boxes and only show them if the create account box is checked.

    The best I have managed so far is to have both boxes hidden, then just one of the boxes show when the check box is selected, but then, that box would not hide when the check box was unselected.

    I got in a bit of a mess so have reverted back to standard. You can see my layout here:
    http://www.legerereeds.co.uk/supplies/test/index.html

    I think the standard layout could be a little confusing - customers might think they have to enter their password then click on the login button that is along side the password box.

    Any help would be much appreciated.
    Thanks
    Lee

    #2
    Using a bit of Blue Peter style cut and past, I have added

    Code:
    <script>
    function ShowHideBox (it, box) {
      var vis = (box.checked) ? "visible" : "hidden";
      document.getElementById(it).style.visibility = vis;
    }
    </script>
    Above the BothAddresses Table in Checkout Page 0

    and added

    onclick="ShowHideBox('password', this)"

    to the Create Account checkbox, here

    Code:
          <input type="checkbox" id="idCREATEANACCOUNT" name="CREATEANACCOUNT" onclick="ShowHideBox('password', this)" value="CREATEANACCOUNT" <actinic:block if="%3cactinic%3avariable%20name%3d%22CustomerAccountsCreationPolicy%22%20%2f%3e%20%3d%3d%203" >Checked</actinic:block> tabindex="NETQUOTEVAR:TABINDEXINVOICECREATEANACCOUNT" style="border: 0; background: <actinic:variable name="CheckoutBG" />;" /><br/>(username will be your email address)
    and put a <div id="password"> </div> around the password prompt and input box, like this

    Code:
       <td class="InvoiceField" align="right"><div id="password">
          <actinic:variable name="CheckoutEnterPasswordCaption" /><span id="idNEWCUSTOMERPASSWORDlabel" class="actrequired"> *</span>
          <input type="password" name="NEWCUSTOMERPASSWORD" id="idNEWCUSTOMERPASSWORD" size="20" maxlength="60" tabindex="NETQUOTEVAR:TABINDEXNEWCUSTOMERPASSWORD"/></div>
       </td>
    but this only works for one of the password boxes as the id="password" can only be used in one position. Also, the box is visible when the page first loads and only toggles on and off once the Create account checkbox is selected.

    Thanks for any help.

    Comment


      #3
      I've got this working by putting both password boxes in the same cell so only one id is needed.

      I've also added style="visibility:hidden;" so the password prompt and input box is now

      <div id="password" style="visibility:hidden;">

      This all seems to be working as I want, but as I know nothing about Java, I would be grateful for any comments regarding the method used, any unseen problems, etc.

      Thanks
      Lee

      Comment


        #4
        One thing to check is that the code works when the page loads or is returned because of an error.

        In these cases, you may need some code that runs when the page has loaded that checks the checkbox state and sets the visibility accordingly. Perhaps added to the onload="...." code in the <body .....> tag. E.g in your Overall Layouts amend the </head><body ...> code to be:
        Code:
        <script type="text/javascript">
          function managepasswd(){
            if (document.getElementById('password')) ShowHideBox('password', document.getElementById('idCREATEANACCOUNT'));
          }
        </script>
        </head>
        <body onload="managepasswd();......
        N.B. untested.



        You'll have to test in assorted browsers too as they differ in how they pre-set form fields on page reloads.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment

        Working...
        X