Jump to content

Xiang

Caspio Guru
  • Content Count

    75
  • Joined

  • Last visited

  • Days Won

    9

Reputation Activity

  1. Like
    Xiang got a reaction from JEllington in Formatting Date In Calendar Popup   
    Hi Jan,
     
    I think, you can add this code to the Footer (do not forget clicking the Source button and changing FIELDNAME to the name of your field):
    <SCRIPT LANGUAGE="JavaScript">      var myDate = new Date();      myDate.setFullYear(myDate.getFullYear()+1);      var myMonth = myDate.getMonth() + 1;      if (myMonth<10) {myMonth = "0" + myMonth;}      var myDay = myDate.getDate();      if (myDay<10) {myDay = "0" + myDay;}      var myYear = myDate.getFullYear();      var result = myDay + "." + myMonth + "."  + myYear;      document.getElementById("InsertRecordFIELDNAME").value=result; </SCRIPT> When a DataPage opens, the current date in the "dd.mm.yyyy" format is entered to the field.
     
    I'll be grateful, if you tell me if the code works.

    Have a nice day!
  2. Like
    Xiang got a reaction from codell in Automatic Redirect Based On The Availability Of Required Parameters   
    Hi codell,
     
    How are you doing?
     
    I think, it's better to create an App Parameter (for example, name it "RedirectURL" and enter the URL of your DataPage as value).
    Then add a Header&Footer element to your DataPages, select the Header element, click the Source button and enter the code like following:
    <SCRIPT LANGUAGE="JavaScript"> var ValueParam='[@testParam]'; var redirectURL='[@app:RedirectURL]'; if(ValueParam.length==0) window.location.assign(redirectURL); </SCRIPT> Enter the name of your parameter instead of "testParam" and the name of your App Parameter instead of "RedirectURL".
     
    I'll be grateful, if you tell me if the code works or if any errors occur.

    Have a nice day!
  3. Like
    Xiang got a reaction from aam82 in Acknowledgement Email Multiple Emails Via Parameters   
    Hi Flosie,
     
    How are you doing?
     
    I think, you can use the following steps:
    Add a Virtual field and select a Hidden FormElement for it, then add the Header&Footer element, select the Footer, click the Source button and enter the code:
    <SCRIPT LANGUAGE="JavaScript"> function emails() { var Regional_Manager = "Regional_Manager"; var Manager = "Manager"; var Submitter = "Submitter"; Regional_Manager = "InsertRecord" + Regional_Manager; Manager = "InsertRecord" + Manager; Submitter = "InsertRecord" + Submitter; var email_Regional_Manager = document.getElementsByName(Regional_Manager)[0].value; var email_Manager = document.getElementsByName(Manager)[0].value; var email_Submitter = document.getElementsByName(Submitter)[0].value; var emailsList = email_Regional_Manager + ";" + email_Manager; if (email_Submitter.length>3) result_email = emailsList + ";" + email_Submitter; document.getElementById("cbParamVirtual1").value = emailsList; } document.getElementById("caspioform").onsubmit=emails; </SCRIPT> And then select your Virtual field as an address for your Acknowledgment email.
    Please note, if the Virtual Field is not the first, you should change the "cbParamVirtual1" to the correspond number, for example, to "cbParamVirtual3".
     
    Could you please let me know, if it works?
     
    Have a nice week-end!
  4. Like
    Xiang reacted to ezIQchad in Recording "record Count" Into Data Table?   
    You could pass that as a parameter to an "Update Data Page" that auto-submits, but DON'T DO THIS
     
    This is poor database design. Use a view to count the records on display.
  5. Like
    Xiang reacted to ezIQchad in Hide Specific Blank Fields In Emails   
    Email clients don't allow <style> .xyz{ style: value;} </style>, so this answer is wrong.
    Correct answer below
    You could add a style section to the email and use the examples from
     
    http://forums.caspio.com/index.php/topic/5501-conditional-formatting-trick/
     
    <div class="some[@field:some]"></div>
     
    .some { display: none;}
     
    When field_some is blank .some will render the div not displayed
  6. Like
    Xiang reacted to ezIQchad in Id="caspioform" Scroll Height   
    Hello,
    Another formatting trick!
     
    I previously had challenges getting Caspio Forms to scroll properly. Then I learned about viewport in CSS -> https://web-design-weekly.com/2014/11/18/viewport-units-vw-vh-vmin-vmax/
    #caspioform {   overflow: auto;   height: calc(100vh - 96px); } I use calc() to take into account the header. If you use calc the spaces between the values and the operator(-,+,*,/) is required.
  7. Like
    Xiang reacted to mmorales in Calculating Difference In Dates   
    In a table that I have, I have a date field that indicates the date an order was placed. I would like to create a calculated field in my datapage that will indicate how long it has been since the order was open (that is, the difference between today's date and the order creation date). Is there any way to do this? I know it will involve Datediff but I am unsure of how to insert today's date automatically.
     
    Ex.
    Order Created - 1/20/16
    Today's Date - 2/12/16
     
    The expected output would be 23. 
     
    Thank you.
     
    EDIT: So I've implemented this using the following formula: DATEDIFF(day,OrderDate, GETUTCDATE()) and it works correctly but now I need this to ONLY count business days (at the moment, it is counting weekends as well).
     
    EDIT 2: I've figured it out. I will leave the answer here for posterity:
     
    To calculate the difference in dates (only considering business days), enter the following into your calculated field:
     
    select (DATEDIFF(dd,@StartDate, @EndDate))     - (DATEDIFF(ww,@StartDate, DATEADD(dd,-1,@EndDate)) * 2)  - (CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 else 0 end) - (CASE WHEN DATENAME(dw, @EndDate) = 'Sunday' THEN 1 else 0 end)   where you replace @StartDate and @EndDate with your corresponding fields (if you're calculating days from today, then use GETUTCDATE() for @EndDate).
  8. Like
    Xiang reacted to ezIQchad in Conditional Formatting Trick   
    Check out this trick I stumbled upon.
     
    Put Caspio Variables into your Classes so you can use CSS to dynamically style your pages.
    (js not required)
     
     
    Div to dynamically format 
    <div class="action[@field:action]"></div> css
    .actionCall { background-image: URL("../img/call.png"); } .actionEmail { background-image: URL("../img/email.png"); } .actionText { background-image: URL("../img/text.png"); } Dynamic Elements - load all options, and hide all but needed
    <a class="btnFile fileName[@field:FileName]" href="../some/dir/[@field:FileName]">Download</a> <a class="btnLink fileLink[@field:FileLink]" href="[@field:FileLink]">View File</a> css
    /*-- when [@field:***] is null, hide the div --*/ .fileName, .fileLink { display: none; } Hope this helps
     
    Think Easy
    CHAD
    -I know the Title of this Forum is "Ask....", but IDK where else to share stuff like this.
  9. Like
    Xiang reacted to ezIQchad in Tabbed Interface: Js Vs Iframe?   
    I don't do anything special. Check out my code...
    Parent Page - leadinfocenter.html (LIC)
    <html> <head> <meta charset="utf-8"> </head> <body onLoad="setIfrSrc()"> <!-- frmPerson -->     <div id="frmPerson" class="licFrame fr1">         <div class="divHeader dh2">             <h5>People</h5>             <a href="javascript:showHide('ifrPerson')" id="btnHide" class="btnShowHide"></a>             <a onclick="window.ifrPerson.location.href = 'lic-person.html'" class="ifrRefresh"></a>             <a onclick="popupWindow('addPerson.html', 438, 720)" class="addRecord"></a>         </div>         <div id="ifrDiv">                                    <iframe name="ifrPerson" class="licIframe" id="ifrPerson"></iframe>         </div>                                 </div><!-- frmPerson --> <script> //set iframe source function setIfrSrc() { varLeadID = getQueryVariable("LeadID"); document.getElementById('ifrPerson').src = 'lic-person.html?LeadID='+varLeadID; document.getElementById('ifr***').src = 'lic-***.html?LeadID='+varLeadID; }   </script> </body>
    </html>
     
    Child Page - lic-person.html
    <html> <head> <meta charset="utf-8"> </head> <body onload="resizeFrame('ifrPerson')"> <div id="ifr" class="ifrContent killHeader licIfr"> <script type="application/javascript" src="http://b5.caspio.com/scripts/e1.js"></script> <script type="application/javascript">try{f_cbload("88appKey88","http:");}catch(v_e){;}</script> </div> <script src="js.js"></script> </body> </html> javascript to size the iframe
    //resize LIC iframe on iframe load function resizeFrame(ifrName) { // Call out to the parent iframe. var ifrContentH = document.getElementById('ifr').scrollHeight; if (ifrContentH > 32) { window.frameElement.ownerDocument.getElementById(ifrName).style.height = ifrContentH+'px'; } else { window.frameElement.ownerDocument.getElementById(ifrName).style.height = '0px'; } } 
  10. Like
    Xiang reacted to mparks in Tabbed Interface: Js Vs Iframe?   
    Here's a technique we use for tabbed interface. It uses a Bootstrap framework which has responsiveness built-into it...the embedded Caspio Datapages still take a little work to become responsive but it can be done....
     

    <ul class="nav nav-pills">           <li class="active">                   <a href="#" onclick="TabOne.html">Tab One</a>           </li>            <li>                   <a href="#" onclick="TabTwo.html">Tab Two</a>            </li> </ul>   If you need to pass parameters between the Caspio datapages that are embedded in the two html pages...then you can use this technique which uses the new localStorage object that is built into your html web browser (note you will need to clear the localStorage object at some point after leaving the tabbed page).  The example below is passing a variable named ID back and forth between the two tab pages.     <ul class="nav nav-pills">       <li class="active">           <a href="#" onclick="getTabOneUrl()">Tab One</a>       </li>       <li>          <a href="#" onclick="getTabTwoUrl()">Tab Two</a>       </li> </ul>  
    Here's the javascript for the getTabOneUrl() and getTabTwoUrl() functions....   $(document).ready(function() {   function getUrlVars() {     var vars = [], hash;     var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');     for(var i = 0; i < hashes.length; i++) {         hash = hashes.split('=');         vars.push(hash[0]);         vars[hash[0]] = hash[1];     }     return vars; }   var Id = getUrlVars()["ID"];   if(localStorage.getItem('Id') == null){     localStorage.setItem('Id', Id)  }  else {     Id = localStorage.getItem('Id'); }   function getTabOneUrl() {       window.location.href = "TabOne.html?ID=" + Id; }   function getTabTwoUrl() {       window.location.href = "TabTwo.html?ID=" + Id; }   }
     
    Here are a bunch of free bootstrap templates...http://startbootstrap.com/template-categories/all/
     
    Here's where to get bootstrap...http://getbootstrap.com/
  11. Like
    Xiang reacted to ezIQchad in How To Monitor App User Activity?   
    I don't know anything about Omniture, but I know you could create a custom solution that use Auto-Submitted data pages to create records in a User Log table.
  12. Like
    Xiang reacted to ezIQchad in Error Inserting Row   
    Search for a character that could be messing with the import. I encountered this before, and I think it was an apostrophe.
     
    Search for and omit...
    ' (apostrophe) , (comma) ; (semi-colon) ` (tilde) There could be more, but I bet it's a special character problem
  13. Like
    Xiang reacted to nmalawskey in Conditional Field Display In Notification Email   
    I actually figured this out late last night. I just passed <ul><li>Information</li></ul> as the checkbox value, then inserted it into the email as an html value. 
     
    So it auto-builds the list, and doesn't show white space where a button has not been checked. 
     
    Cheers,
    Nick
  14. Like
    Xiang reacted to nmalawskey in Jquery To Hide/show Divs Onclick!   
    Never mind. Instead of showing/hiding the div, I used jquery to show/hide the text. Solved the issue.
     
    If anyone ever needs it:
     
    <script>
      $(document).ready(function(){         $('.moreinfo').hide();         $('.more').click(function (ev) {            var t = ev.target            $('#info' + $(this).attr('target')).toggle(500, function(){               $(t).html($(this).is(':visible')? 'I\'m done reading more' : 'Read more')            });            return false;         }); }); </script>   <p class="moreinfo" id="info1">text text text text </p>   <a class="more" target="1">Read More</a> 
  15. Like
    Xiang got a reaction from Aurora in I Want To Share Solution With Two Responsive Tabulars On A Webpage   
    Hi everyone,


    I hope you are doing well.


    I like solution for Responsive Tabular DataPages, but if I deploy two DataPages on a webpage, names of the second DataPage replace names of the first.

    I've found the solution and want to share it:

    Edit the second DataPage, go to the "Configure Results Page Fields" step, go to the header of the second DataPage, find the part:

    #tabular table[class^=cbResultSetTable] td:nth-of-type(1):before { content: "Insert Label Here"; font-weight: bold; }
    #tabular table[class^=cbResultSetTable] td:nth-of-type(2):before { content: "Insert Label Here"; font-weight: bold; }
    #tabular table[class^=cbResultSetTable] td:nth-of-type(3):before { content: "Insert Label Here"; font-weight: bold; }
    #tabular table[class^=cbResultSetTable] td:nth-of-type(4):before { content: "Insert Label Here"; font-weight: bold; }
    }
    </style>
    <div id="tabular">
    <!-- Responsive Code End -->


    And replace all "#tabular" and "tabular" to "#myID" and "myID", then the whole code will be like follows:
    #myID table[class^="cbResultSetTable"] td:nth-of-type(1):before { content: "Insert Label Here"; font-weight: bold; } #myID table[class^="cbResultSetTable"] td:nth-of-type(2):before { content: "Insert Label Here"; font-weight: bold; } #myID table[class^="cbResultSetTable"] td:nth-of-type(3):before { content: "Insert Label Here"; font-weight: bold; } #myID table[class^="cbResultSetTable"] td:nth-of-type(4):before { content: "Insert Label Here"; font-weight: bold; } } </style> <div id="myID"> <!-- Responsive Code End --> If you have any problems - feel free to ask, I'll be glad to help.

    Have a nice day!

     
  16. Like
    Xiang got a reaction from MayMusic in Possible To Color Code Rows By Group In A Tabular Report?   
    Hi MikeP,
     
    How are you?
     
    I've written the code (you can add an HTML Block, place it the last element, click the Source button and enter the code):
    Do not forget to change "id" in two places ([@field:id]) - enter the name of your field with unique value (usually it is a field with the Autonumber DataType) and enter your values in blocks "first possible value", "second possible value". You can use as many blocks as you want.
    <div id="[@field:id]"></div> <SCRIPT LANGUAGE="JavaScript"> var line_id='[@field:id]'; var number_records_per_page = 25; //Records per page var line=document.getElementById(line_id).parentNode.parentNode; var elems = line.getElementsByTagName("td"); var myColor = ""; var mybgColor = ""; var colorAll = false; var comparisonText = ""; if(elems[0].innerHTML==" ") {    var isGroup = elems[0].parentNode.previousSibling.getElementsByTagName("td")[0];    if(isGroup.innerHTML==" ")    {       for(i = 1; i < number_records_per_page; i++)       {          isGroup = isGroup.parentNode.previousSibling.getElementsByTagName("td")[0];          if(isGroup.innerHTML!=" ") break;        }     }    comparisonText = isGroup.innerHTML; } else {   comparisonText = elems[0].innerHTML; } //first possible value if (comparisonText =="test"  || comparisonText =="test (Cont.)")  //enter your value instead of test {    myColor="blue"; //enter your text color instead of blue    mybgColor="yellow"; //enter your background color instead of yellow    var colorAll = true; } //second possible value if (comparisonText =="test" || comparisonText =="test (Cont.)") //enter your value instead of test {     myColor="red"; //enter your color instead of red     mybgColor="green"; //enter your background color instead of green     var colorAll = true; } if(colorAll) {    for (var i=0, m=elems.length; i<m; i++)    {       elems[i].style.color=myColor;       elems[i].style.backgroundColor=mybgColor;     } } </SCRIPT> I'll be grateful, if you tell me if the code works.

    Have a nice day!
  17. Like
    Xiang got a reaction from MayMusic in Can I Use A Aggregate (Total) In Js In The Footer ?   
    Hi peterhanse,
     
    Welcome to the Forum!
    How are you?
     
    I think, you can use the following code:
    <script> var column_number = 1; var myTable = document.getElementsByName("cbTable")[0]; var myRows = myTable.getElementsByTagName("tr"); var lastRow = myRows.length - 1; var myCells = myRows[lastRow].getElementsByTagName("td"); var myTotal = parseFloat(myCells[column_number].innerHTML); var paard = "voeg uw paard toe!"; var voegtoe = "upgrade uw acount!"; if(myTotal>0) { document.write("<p>Link: " + paard.link("http://google.nl") + "</p>") } else { document.write("<p>Link: " + voegtoe.link("http://caspio") + "</p>") } </script> Where column_number is the number of the Aggregation.
    If you use only one Aggregation, it'll be "1".
     
    I'll be grateful, if you tell me if the code works.

    Have a nice day!
  18. Like
    Xiang got a reaction from MayMusic in Validate Past And Future Dates   
    Hi everyone,
     
    I'd like to share this code, that validates if the entered date is correct.
    Enter the name of your field instead of "myDate", enter the correct numbers for allowedDaysInPast  and allowedDaysInFuture variables, enter texts of your messages.
    If you don't want to validate in past or in future you can delete the correspond block.
    Then add a Header@Footer element, select the Footer element, click the Source button and enter the code.
    <SCRIPT LANGUAGE="JavaScript"> function validate_dates() { var dateFieldName = "myDate"; var allowedDaysInPast = 1; var deniedMessagePast = "The entered date cannot be earlier than yesterday"; var allowedDaysInFuture = 1; var deniedMessageFuture = "The entered date cannot be later than tomorrow"; dateFieldName = "InsertRecord" + dateFieldName; var entered_value = document.getElementById(dateFieldName).value; var entered_date = new Date(entered_value); //Start of Validating in past var todayP = new Date(); var allowedDatePast = new Date(todayP.setDate(todayP.getDate() - allowedDaysInPast)); allowedDatePast = allowedDatePast.setHours(0,0,0,0); if(entered_date < allowedDatePast)    {       alert(deniedMessagePast);       return false;    } //Finish of validating in past //Start of Validating in future var todayF = new Date(); var allowedDateFuture = new Date(todayF.setDate(todayF.getDate() + allowedDaysInFuture)); allowedDateFuture = allowedDateFuture.setHours(23,59,59); if(entered_date > allowedDateFuture)    {       alert(deniedMessageFuture);       return false;    } //Finish of validating in future } document.getElementById("caspioform").onsubmit=validate_dates; </SCRIPT> I'll be grateful, if you tell me if the code works or if any errors occur.

    Have a nice day!
  19. Like
    Xiang got a reaction from Aurora in Formatting Date In Calendar Popup   
    Hi Jan,
     
    I think, you can add this code to the Footer (do not forget clicking the Source button and changing FIELDNAME to the name of your field):
    <SCRIPT LANGUAGE="JavaScript">      var myDate = new Date();      myDate.setFullYear(myDate.getFullYear()+1);      var myMonth = myDate.getMonth() + 1;      if (myMonth<10) {myMonth = "0" + myMonth;}      var myDay = myDate.getDate();      if (myDay<10) {myDay = "0" + myDay;}      var myYear = myDate.getFullYear();      var result = myDay + "." + myMonth + "."  + myYear;      document.getElementById("InsertRecordFIELDNAME").value=result; </SCRIPT> When a DataPage opens, the current date in the "dd.mm.yyyy" format is entered to the field.
     
    I'll be grateful, if you tell me if the code works.

    Have a nice day!
  20. Like
    Xiang got a reaction from Aurora in Summary Report For Many Yes/no Fields   
    Hi DataCobalt,
     
    How are you?
     
    I think, you can use this formula in your Aggregation field:
    Count(case when FIELDNAME=0 then 1 else NULL end) Or this formula to calculate the percentage:
    100*Count(case when FIELDNAME=0 then 1 else NULL end)/Count I'll be grateful, if you tell me if the code works.

    Have a nice day!
  21. Like
    Xiang got a reaction from Uriah in Display Age Based On Birthdayjavascript   
    Good morning Spazz,
     
    How are you doing?
     
    I think, you can add an HTML Block on your Report and enter the following code:
    <script>var birth_day = '[@field:birthday]'; var date_birth = new Date(birth_day); var date_today =  new Date(); var timeDiff = Math.abs(date_today.getTime() - date_birth.getTime()); var diffYears = Math.ceil(timeDiff / (1000 * 3600 * 24 * 365.25));  document.write(diffYears); </script> Insert the name of your field instead of "birthday".
     
    I'm learning the JavaScript now, so, I'll be grateful, if you tell me if the code works.
     
    Have a nice day!
  22. Like
    Xiang got a reaction from nickword in How To Change A Label Via Javascript   
    Good morning Sidhartha,
     
    How are you?
     
    I think, you can use the following code to change the text of a label on a Submission Form:
    document.getElementById("InsertRecordFEILDNAME").parentNode.previousSibling.firstChild.innerHTML="NEW LABEL"; Please, enter the name of your field instead of FIELDNAME and your text instead of "new label".
     
    I'll be grateful, if you tell me if the code works.
     
    Have a nice day!
  23. Like
    Xiang reacted to DataCobalt in Use This Forum For Posting Successful Workarounds/advanced Usage?   
    Hi all,
     
    I just wanted to see if people would have any interest in posting or having other's post about ways they have used Caspio that is not in any of the TechTips or basic info on howto.caspio.com .
     
    These forums have helped me out a lot while building my application and I think it would be a great way for any of us to give back a little by building a knowledge base to help new users before they ask questions.
     
    I've attached a poll to this and maybe if it gets enough interest the mods can have a specific sub-forum for these topics?
     
    Hope everyone is having a great work week!
     
     
  24. Like
    Xiang got a reaction from buildmy401k in Form Auto Submit And Calc Js   
    Good morning Allen,

     

    How are you doing?

     

    In Java Script, "{" means "Start" and "}" means "Finish". So, if you want to do several actions in a function, I think, it's better don't write "Finish" and then "Start" again between them, the function doesn't execute any code after the "Finish" sign.

     

    In setTimeout('document.forms["caspioform"].submit()',0); }, "0" means how long a DataPage waits before auto submits. It's better to use "1000", at least "100" milliseconds, then you allow a DataPage to load and then autosubmit it.

     

    And if you want to call another function before autosubmit, you can write the same code but for another function:

    setTimeout('calculate()',500); }

     

    Then the whole code will be like:


    <SCRIPT LANGUAGE="JavaScript">
     
     function calculate()
     {
       var v_Current_Plan = parseFloat(document.getElementById("InsertRecordCurrent_Plan").value);
       var v_Current_Fee = parseFloat(document.getElementById("InsertRecordCurrent_Fee").value);
       var v_Rate= .08;
       var v_total  = (((v_Current_Plan * v_Rate) + v_Current_Plan) - (((v_Current_Plan * v_Rate) + v_Current_Plan) * v_Current_Fee));
       document.getElementById("InsertRecordCurrent_Plan").value = Math.round(v_total);

       var v_New_Plan = parseFloat(document.getElementById("InsertRecordNew_Plan").value);
       var v_New_Fee = parseFloat(document.getElementById("InsertRecordNew_Fee").value);
       var v_Rate= .08;
       var v_total  = (((v_New_Plan * v_Rate) + v_New_Plan) - (((v_New_Plan * v_Rate) + v_New_Plan) * v_New_Fee));
       document.getElementById("InsertRecordNew_Plan").value = Math.round(v_total);
     }
     
    if(document.getElementById("caspioform")) {
    document.getElementById("caspioform").style.display = 'none';
    setTimeout('calculate()',500);
    setTimeout('document.forms["caspioform"].submit()',1000); }
     
    </script>
    I'm learning the JavaScript now, so, I'll be grateful, if you tell me if the code works.

     

    Have a nice day!

×
×
  • Create New...