How to Show/Hide a div based on day of the week with jQuery

JavaScritpt

  1.  
  2. <script type="text/javascript">
  3.         $(document).ready(function() {
  4.        
  5.         today=new Date()
  6.         thisDay=today.getDay()
  7.        
  8.         $("#sunday").hide();
  9.                 $("#monday").hide();
  10.                 $("#tuesday").hide();
  11.                 $("#wednesday").hide();
  12.                 $("#thursday").hide();
  13.                 $("#friday").hide();
  14.                 $("#saturday").hide();
  15.        
  16.        
  17.         if (thisDay == 0){
  18.            $("#sunday").show();
  19.         }
  20.  
  21.         if (thisDay == 1){
  22.            $("#monday").show();
  23.         }
  24.         if (thisDay == 2){
  25.             $("#tuesday").show();
  26.         }
  27.         if (thisDay == 3){
  28.             $("#wednesday").show();
  29.         }
  30.         if (thisDay == 4){
  31.             $("#thursday").show();
  32.         }
  33.  
  34.         if (thisDay == 5){
  35.             $("#friday").show();
  36.         }
  37.         if (thisDay == 6){
  38.             $("#saturday").show();
  39.         }
  40.        
  41.         });
  42. </script>
  43.  

Html

  1.  
  2. <div id="sunday">
  3.   <h3>Sunday</h3>
  4. </div>
  5. <div id="monday">
  6.   <h3>Monday</h3>
  7. </div>
  8. <div id="tuesday">
  9.   <h3>Tuesday</h3>
  10. </div>
  11. <div id="wednesday">
  12.   <h3>Wednesday</h3>
  13. </div>
  14. <div id="thursday">
  15.   <h3>Thrursday</h3>
  16. </div>
  17. <div id="friday">
  18.   <h3>Friday</h3>
  19. </div>
  20. <div id="saturday">
  21.   <h3>Saturday</h3>
  22. </div>
  23.  

Posted in JavaScript, jQuery | Tagged , , , , , , | Leave a comment

How to change the message “No bookings found.” on Business Catalyst using JavaScript.

First wrap your module with an div like: <div id="app">{module...}</div>

Then include the following JavaScript code:

JavaScript

  1.  
  2.  
  3. <script type="text/javascript">
  4.             $(document).ready(function() {
  5.                 var td = document.getElementById(‘app’).innerHTML;
  6.                 if(td=="No bookings found."){
  7.                     document.getElementById(‘app’).innerHTML = "No events at this time";
  8.                 }
  9.             });
  10. </script>
  11.  

Please, remove any blank space or break line between the div and module tag.

Posted in Business Catalyst / GoodBarry | Tagged , , , , , | Leave a comment

How to Force Opt-In automatically instead of having to go into each contacts details – Business Catalyst

just add: &amp;Optin=True at the form action, see example below:

HTML example

  1.  
  2. <form action="/FormProcessv2.aspx?WebFormID=10090&amp;OID={module_oid}&amp;OTYPE={module_otype}&amp;EID={module_eid}&amp;CID={module_cid}&amp;Optin=True" enctype="multipart/form-data" onsubmit="return checkWholeForm13472(this)" method="post" name="catwebformform13472">
  3.  

Posted in Business Catalyst / GoodBarry | Tagged , , , , , | Leave a comment

How to add a surcharge to the Amex option for the checkout form in the Online Store – Business Catalyst

Use onchange to alert the customer that a charge will occur and then the function doMath() calculates the surcharge.

JavaScript

  1.  
  2. <script type="text/javascript">
  3.      function checkSel(obj) {
  4.       var ind = obj.selectedIndex;
  5.       if  (ind == 3) {
  6.           alert(‘This Card incurs a 3.5% Surcharge.’);  
  7.       }
  8.      }
  9.    
  10.      function  doMath() {
  11.    
  12.       if (CardType = "AMEX") {
  13.        var one = eval(document.catwebformform7818.Amount.value)
  14.        var prod = one  *   1.03
  15.       document.catwebformform7818.Amount.value=custRound(prod,2);}
  16.       }
  17.      
  18.      function custRound(x,places) {
  19.       return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
  20.      }
  21.     </script>
  22.  

Add the onchange into the dropdown:

HTML

  1.  
  2. <div class="item"><label>Card Type <span class="req">*</span></label> <select class="cat_dropdown" id="CardType" onchange="checkSel(this);" name="CardType">
  3.                             <option value="1" selected="true">Visa</option>
  4.                             <option value="2">Master Card</option>
  5.                             <option value="3">Bank Card</option>
  6.                             <option value="4">American Express</option>
  7.                             <option value="5">Diners Club</option>
  8.                             </select> </div>
  9.  

Then add the onclick to the submit button to action the Maths script:

  1.  
  2. <input id="catwebformbutton" onclick="doMath()" type="submit" value="Submit" />
  3.  

If you want apply this for Diners card as well, use the following:

  1.  
  2.  if (ind == 3 || ind == 4) { alert(‘AMEX incurs a 3% Surcharge.\n Total Amount will be updated upon hitting the submit button.’); }
  3.  

Posted in Business Catalyst / GoodBarry | Tagged , , , , , , , , , , | Leave a comment

How to Create a Drop Down Select with Links without a form submit.

HTML

  1.  
  2. <form action="../">
  3. <select onchange="window.open(this.options[this.selectedIndex].value,’_top’)">
  4.     <option value="contact.html">Contact Page</option>
  5.     <option value="http://www.apple.com">Apple</option>
  6.     <option value="http://www.yahoo.com">Yahoo</option>
  7.     <option value="http://www.google.com">google</option>
  8.     <option value="about.html">About Us</option>
  9. </select>
  10. </form>
  11.  

Demo

Posted in HTML, JavaScript | Tagged , , , , , , , | Leave a comment

How to Submit Form on Selection of Dropdown Item

HTML

  1.  
  2. <select class="dropdown" id="form2" name="form2" onchange="this.form.submit();">
  3.     <option value="*">– All –</option>
  4.     <option selected="selected" value="NSW">NSW</option>
  5.     <option value="WA">WA</option>
  6.     <option value="QLD">QLD</option>
  7.     <option value="VIC">VIC</option>
  8.     <option value="ACT">ACT</option>
  9.     <option value="NT">NT</option>
  10.     <option value="NZ">NZ</option>
  11.     </select>
  12.  

Posted in HTML, JavaScript | Tagged , , , | 1 Comment

How to Automatically Re-size Images for iPhones/ iPods

CSS

  1.  
  2. @media screen and (max-device-width: 480px){
  3.     img{
  4.         max-width:100%;
  5.         height:auto;
  6.     }
  7. }
  8.  

Posted in CSS | Tagged , , , , , | 1 Comment

How to Apply CSS styles to iPhones/iPods only

CSS

  1.  
  2. @media screen and (max-device-width: 480px){
  3.     /* All iPhone only CSS goes here */
  4. }
  5.  

Posted in CSS | Tagged , , , , , | Leave a comment

How to Detect iPhone with JavaScript

Use Javascript to detect then apply different style for iPhone.

JavaScript

  1.  
  2. if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
  3.     if (document.cookie.indexOf("iphone_redirect=false") == -1) {
  4.         window.location = "http://yoursite.com/iphone";
  5.     }
  6. }
  7.  

Posted in JavaScript | Tagged , , | Leave a comment

Basic Default CSS Print Template

CSS

  1.  
  2. /* Set default width, margin, float, and
  3.    background.  */
  4. body, #wrap, #content, #container, {
  5.    width: 100%;
  6.    margin: 0;
  7.    float: none;
  8.    background: #fff url(none);
  9. }
  10.  
  11. /* Remove any elements not needed in print.
  12.    This would include navigation, ads, sidebars, etc. */
  13. #nav, .noprint, #footer {
  14.    display: none;
  15. }
  16.  
  17. /* Set body font face, size, and color.
  18.    Consider using a serif font for readability. */
  19. body {
  20.    font: 1em Arial, "Times New Roman", Times, serif;
  21.    color: #000;
  22. }
  23.  
  24. /* Set heading font face, sizes, and color.
  25.    Diffrentiate your headings from your body text.
  26.    Perhaps use a large sans-serif for distinction. */
  27. h1,h2,h3,h4,h5,h6, p, span {
  28.    font-family: Georgia, Arial, sans-serif;
  29.    color: #000;
  30. }
  31. h1 { font-size: 250%; }
  32. h2 { font-size: 175%; }
  33. h3 { font-size: 135%; }
  34. h4 { font-size: 100%; font-variant: small-caps; }
  35. h5 { font-size: 100%; }
  36. h6 { font-size: 90%; font-style: italic; }
  37.  
  38. /* Make hyperlinks more usable.
  39.    Ensure links are underlined, and consider appending
  40.    the URL to the end of the link for usability. */
  41. a:link, a:visited {
  42.    color: #ff9900;
  43.    text-decoration: underline; }
  44.    
  45. #content a:link:after, #content a:visited:after {
  46.    content: " (" attr(href) ") ";
  47. }
  48.  

HTML

  1.  
  2. <link rel="stylesheet" href="print.css" type="text/css" media="print" />
  3.  

Posted in CSS | Tagged , , , , , | 2 Comments