Announcement

Collapse
No announcement yet.

Capatalize words script but how.

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

    Capatalize words script but how.

    Hi there,
    Now then, here is a challenge.
    I get fed up with people entering their address deatils in lower case.

    I have found this script:
    function capitalizeWords(string) { var tmpStr, tmpChar, preString, postString,
    strlen; tmpStr = string.toLowerCase(); stringLen = tmpStr.length; if (stringLen
    > 0) { for (i = 0; i < stringLen; i++) { if (i == 0) { tmpChar = tmpStr.substring(0,1).toUpperCase();
    postString = tmpStr.substring(1,stringLen); tmpStr = tmpChar + postString; } else
    { tmpChar = tmpStr.substring(i,i+1); if (tmpChar == " " && i < (stringLen-1))
    { tmpChar = tmpStr.substring(i+1,i+2).toUpperCase(); preString = tmpStr.substring(0,i+1);
    postString = tmpStr.substring(i+2,stringLen); tmpStr = preString + tmpChar + postString;
    } } } } return tmpStr; }
    It is actually within dreamweaver, but how could it be used within the checkout pages to capatalize the customers details?

    #2
    In Act_CheckoutPrimary.html just after the line:-

    <SCRIPT LANGUAGE="JavaScript" SRC="actinicextras.js" TYPE="text/javascript"></SCRIPT>

    put the code:-

    Code:
    <script language=JavaScript>
    <!-- 
    function capitalizeWords(string) { 
     var tmpStr, tmpChar, preString, postString, strlen; 
     tmpStr = string.toLowerCase();
     stringLen = tmpStr.length;
     if (stringLen > 0) 
      { 
      for (i = 0; i < stringLen; i++) 
       { 
       if (i == 0) 
        { 
        tmpChar = tmpStr.substring(0,1).toUpperCase(); 
        postString = tmpStr.substring(1,stringLen);
        tmpStr = tmpChar + postString; 
        } 
       else 
        { 
        tmpChar = tmpStr.substring(i,i+1);
        if (tmpChar == " " && i < (stringLen-1)) 
         { 
         tmpChar = tmpStr.substring(i+1,i+2).toUpperCase();
         preString = tmpStr.substring(0,i+1); 
         postString = tmpStr.substring(i+2,stringLen);
         tmpStr = preString + tmpChar + postString; 
         } 
        } 
       } 
      } 
     return tmpStr; 
    }
    // -->
    </script>
    And in the checkout templates Act_Order01.html 02, 03, etc in the fields you want fixed. Look for the <input...> tags and change e.g.

    Code:
         <input type="TEXT" name="INVOICENAME" size="20" maxlength="40"
    		          value="NETQUOTEVAR:INVOICENAME">
    
    to
    
         <input type="TEXT" name="INVOICENAME" size="20" maxlength="40"
    		          value="NETQUOTEVAR:INVOICENAME" onchange="this.value = capitalizeWords(this.value)">
    Norman
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Hi Norman,
      Thank you very much, that works as it should.
      I left the phone number and email address fields alone as you dont really want to alter peoples email address as they type it.

      I also went one step further and using the method of implementing that code i also added to Act_CheckoutPrimary.html :



      <script language=JavaScript>
      <!--
      function stringToUppercase(inputString)
      {
      return inputString.toUpperCase();
      }
      // -->
      </script>
      And then to the postcode field in Aorder01.html

      <script language=JavaScript>
      <!--
      function stringToUppercase(inputString)
      {
      return inputString.toUpperCase();
      }
      // -->
      </script>
      I am now going to implement the same scripts to the alternate delivery address fields.

      Comment


        #4
        You don't really need a separate function call for that upper case fix. Just do:-

        onchange="this.value=this.value.toUpperCase();"

        Norman
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          I thought that might be the case after I did it as the uppercase bit is already within the original script.

          Thanks for all your help, its going to save me messing about doing the job manually when orders come in.

          I resalise Jan has a mole that does a similar job and a lot more.

          thanks

          Simon

          Comment


            #6
            I don't have act_checkoutprimary on my site, as it is based on the Business template.

            You don't happen to know what the equivalent would be for this template would you?

            Comment


              #7
              I don't have act_checkoutprimary on my site, as it is based on the Business template.
              Ooops. That template may, in fact, be called Act_PrimaryCheckout.html.

              What do you have in Design / Options / Layouts / Checkout Pages Layout? Pressing the Edit button will let you know.

              Norman
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                Originally posted by NormanRouxel
                Ooops. That template may, in fact, be called Act_PrimaryCheckout.html.

                What do you have in Design / Options / Layouts / Checkout Pages Layout? Pressing the Edit button will let you know.

                Norman
                That would be Act_Primary.html in mine. Now why didn't I think of that

                Thanks for your help Norman

                Comment


                  #9
                  I got the first letter of name, address lines 1, 2, & 3 to work OK but address line 4 (which is county on my site) never seems to work

                  here is part of my code

                  Code:
                  NETQUOTEDEL:INVOICEPROMPT003 NETQUOTEDEL:INVOICEPROMPT004
                    <tr>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">NETQUOTEVAR:INVOICEPROMPT004</td>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">
                        <input type="TEXT" name="INVOICEADDRESS1" size="40" maxlength="200" value="NETQUOTEVAR:INVOICEADDRESS1" onchange="this.value=capitalizeWords(this.value)">
                      </td>
                    </tr>
                    NETQUOTEDEL:INVOICEPROMPT004 NETQUOTEDEL:INVOICEPROMPT005
                    <tr>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">NETQUOTEVAR:INVOICEPROMPT005</td>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">
                        <input type="TEXT" name="INVOICEADDRESS2" size="40" maxlength="200" value="NETQUOTEVAR:INVOICEADDRESS2" onchange="this.value=capitalizeWords(this.value)">
                      </td>
                    </tr>
                    NETQUOTEDEL:INVOICEPROMPT005 NETQUOTEDEL:INVOICEPROMPT006
                    <tr>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">NETQUOTEVAR:INVOICEPROMPT006</td>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">
                        <input type="TEXT" name="INVOICEADDRESS3" size="40" maxlength="200" value="NETQUOTEVAR:INVOICEADDRESS3" onchange="this.value=capitalizeWords(this.value)">
                      </td>
                    </tr>
                    NETQUOTEDEL:INVOICEPROMPT006 NETQUOTEDEL:INVOICEPROMPT007
                    <tr>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">NETQUOTEVAR:INVOICEPROMPT007</td>
                      <Actinic:LOCATION TYPE='INVOICEADDRESS4'>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">
                        <input type="TEXT" name="INVOICEADDRESS4" size="40" maxlength="200" value="NETQUOTEVAR:INVOICEADDRESS4" onchange="this.value=capitalizeWords(this.value)">
                      </td>
                      </Actinic:LOCATION>
                    </tr>
                    NETQUOTEDEL:INVOICEPROMPT007 NETQUOTEDEL:INVOICEPROMPT008
                    <tr>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">NETQUOTEVAR:INVOICEPROMPT008</td>
                   	<Actinic:LOCATION TYPE='INVOICEPOSTALCODE'>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">
                        <input type="TEXT" name="INVOICEPOSTALCODE" size="10" maxlength="50" value="NETQUOTEVAR:INVOICEPOSTALCODE" onchange="this.value=this.value.toUpperCase();">
                      </td>
                  	</Actinic:LOCATION>
                    </tr>
                    NETQUOTEDEL:INVOICEPROMPT008 NETQUOTEDEL:INVOICEPROMPT009
                    <tr>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">NETQUOTEVAR:INVOICEPROMPT009</td>
                  	<Actinic:LOCATION TYPE='INVOICECOUNTRY'>
                      <td bgcolor="NETQUOTEVAR:CHECKOUTBG">
                        <input type="TEXT" name="INVOICECOUNTRY" size="20" maxlength="75" value="NETQUOTEVAR:INVOICECOUNTRY" onchange="this.value=capitalizeWords(this.value)">
                      </td>
                  	</Actinic:LOCATION>
                    </tr>

                  I did a veiw source while on my check out pages and saw this (cut from full text)


                  Code:
                   CLASS="actrequiredcolor">City/Town* </SPAN></td><td bgcolor="#d8e4f1"><input type="TEXT" name="INVOICEADDRESS3" size="40" maxlength="200" value="Oxford" onchange="this.value=capitalizeWords(this.value)"></td></tr>  <tr><td bgcolor="#d8e4f1">County</td><td bgcolor="#d8e4f1"><input type="TEXT" name="INVOICEADDRESS4" size="40" maxlength="200" VALUE=""></td></tr>  <tr><td bgcolor="#d8e4f1"><
                  Seems to not ad the new code after invoiceaddress4

                  I have noticed that the line 'county' is never cached when I test my site. While all other fields are, using the 'remember me' function
                  David

                  Comment


                    #10
                    Post an URL so we can see what's happening.

                    Also this can be done via STYLE attribues instead of JavaScript. E.g:

                    <input type="text" style="text-transform:capitalize" .....

                    or

                    <input type="text" style="text-transform:uppercase" .....

                    and no onchange or JavaScript functions needed.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      Have emailed it
                      David

                      Comment


                        #12
                        I just amended my post above. Have a re-read.
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #13
                          So I should dump the Jarva and go for style?
                          David

                          Comment


                            #14
                            It won't hurt to try it and it will be much simpler.
                            Norman - www.drillpine.biz
                            Edinburgh, U K / Bitez, Turkey

                            Comment


                              #15
                              Just noticed JavaScript errors on all your pages. You have missed the </script> tag in Act_Primary.html:
                              Code:
                              return tmpStr; 
                              }
                              // -->
                              <!-- Placeholder of cookie checking javascript code. Do not remove it! -->
                              <Actinic:COOKIECHECK/>
                              should be
                              Code:
                              return tmpStr; 
                              }
                              // -->
                              </script>
                              <!-- Placeholder of cookie checking javascript code. Do not remove it! -->
                              <Actinic:COOKIECHECK/>
                              Norman - www.drillpine.biz
                              Edinburgh, U K / Bitez, Turkey

                              Comment

                              Working...
                              X