Jump to content


Caspio Ninja
  • Content Count

  • Joined

  • Last visited

  • Days Won


Reputation Activity

  1. Thanks
    lmooring reacted to Vitalikssssss in Date+1 and Insert on Submission Form   
    Hi Imooring,
    You can try to use the following code on your Submission Form in order to insert "+1 day" value into your Expire Date field upon user select the date in End Date field:
    <script> function DateAdd() { var a = new Date(document.getElementById('InsertRecordYOUR_FIELD_End_Date').value); a.setDate(a.getDate() + 1); var dd = a.getDate(); var mm = a.getMonth()+1; var yy= a.getFullYear(); var b = mm + '/' + dd + '/'+yy; // you should change an order if you use non-US localization in your Submission Form document.getElementById('InsertRecordYOUR_FIELD_Expiration_Date').value=b; } document.getElementById('InsertRecord_YOUR_FIELD_End_Date').onchange= DateAdd; </script> You should place this code into the Footer of your Submission Form. Please make sure that you have disabled HTML editor.
    Hope this helps.
  2. Like
    lmooring reacted to Mathilda in If..Then Statement in Submission Form   
    I also added a condition to check that fields are not blank. You need to use your field names instead of mine.
    <SCRIPT LANGUAGE="JavaScript">  function check()  { var COMPLEXUNITS= parseFloat(document.getElementById("InsertRecordCOMPLEXUNITS").value); var SIMPLEUNIT = parseFloat(document.getElementById("InsertRecordSIMPLEUNIT").value); var PACKTYPE = document.getElementsByName("InsertRecordPacktype")[0].value;     if( PACKTYPE =='Simple' ) { if (SIMPLEUNIT !=1 || typeof SIMPLEUNIT  == 'undefined' || !SIMPLEUNIT || SIMPLEUNIT.length  === 0 || SIMPLEUNIT  === "" || !/[^\s]/.test(SIMPLEUNIT) || /^\s*$/.test(SIMPLEUNIT) || SIMPLEUNIT.replace(/\s/g,"") === "" ) { window.alert("Value in the SIMPLEUNIT field should be equal 1"); return false; } } else if (PACKTYPE =='Complex'){ if ( COMPLEXUNITS <2 || typeof COMPLEXUNITS == 'undefined' || !COMPLEXUNITS  || COMPLEXUNITS.length  === 0 || COMPLEXUNITS  === "" || !/[^\s]/.test(COMPLEXUNITS ) || /^\s*$/.test(COMPLEXUNITS ) || COMPLEXUNITS .replace(/\s/g,"") === "") {  window.alert("Value in the COMPLEXUNITS field should be grater or equal  2"); return false; } } }  document.getElementById("caspioform").onsubmit=check; </SCRIPT>  
  3. Like
    lmooring reacted to NikkiC in Star ratings   
    I've managed to get the rating to update back to the database  thought I'd post in case anybody else finds it useful:
    <div id="el" class="c-rating"></div> <script src="http://www.cambridgedata.org/Testboard/manager/five-star-rating-master/js/dist/rating.min.js"></script> <script> // target element var el = document.querySelector('#el'); // current rating, or initial rating var currentRating; if ([@field:QA_Tester_Rating#] > 0) { currentRating = [@field:QA_Tester_Rating#]; } else { currentRating = 0; } // max rating, i.e. number of stars you want var maxRating = 5; // callback to run after setting the rating var callback = function(rating) {document.getElementById("EditRecordQA_Tester_Rating").value=(rating); }; // rating instance var myRating = rating(el, currentRating, maxRating, callback); </script> Only thing that's not working is making the value 0 if the field is empty.  So if the field in the table is empty (as it is by default) then the stars don't show at all.  Can anyone help with this bit?
    // current rating, or initial rating var currentRating; if ([@field:QA_Tester_Rating#] > 0) { currentRating = [@field:QA_Tester_Rating#]; } else { currentRating = 0; } Many thanks!
  4. Like
    lmooring reacted to MayMusic in Change A Form Field Value On Submit   
    You can have a script that calls a function on submit to check the box
    <script> document.getElementById('caspioform').onsubmit = function (){ document.getElementById('CHECKBOXID').checked="True"; } </script> Code can go to the footer of the page and "CHECKBOXID" needs to be replaced with actual element ID.
  5. Like
    lmooring reacted to Jan in Calendar - Make Start Date 2 Days After Current (Today's) Date   
    Hello themonitor,
    I think, you can use the following code:
    <SCRIPT LANGUAGE="JavaScript"> function check_date() { var entered_value = document.getElementById("InsertRecordfirst").value; var entered_date = new Date(entered_value); var tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + 1); if(entered_date < tomorrow)    {       alert("Please select a date after tomorrow");       return false;    } var entered_value2 = document.getElementById("InsertRecordsecond").value; if (entered_value2 !="") { var entered_date2 = new Date(entered_value2); if(entered_date2 < tomorrow)    {       alert("Please select a date2 after tomorrow");       return false;    } } var entered_value3 = document.getElementById("InsertRecordthird").value; if (entered_value3 !="") { var entered_date3 = new Date(entered_value3); if(entered_date3 < tomorrow)    {       alert("Please select a date3 after tomorrow");       return false;    } } } document.getElementById("caspioform").onsubmit=check_date; </SCRIPT> Please insert your fieldnames instead of first, second, third.
    I hope, it helps.
  6. Like
    lmooring reacted to Mathilda in Check the Cost is less than Retail   
    try using my code in the footer of the datapage:
    <SCRIPT LANGUAGE="JavaScript">  function check()  {    var v_cost = parseFloat(document.getElementById("InsertRecordFirst_field").value);  var v_retail = parseFloat(document.getElementById("InsertRecordSecond_field").value);     if(v_cost>v_retail) {      window.alert("Cost must be less");  return false; } }  document.getElementById("caspioform").onsubmit=check; </SCRIPT> Replace First_field with field name where you store cost, and Second_field with field name where you store retail amount.
    Hope it helps!
  7. Like
    lmooring reacted to Jan in Enable multiple selection for listbox with virtual fields   
    Hi Rael,
    I think, you can double the code for all listboxes, like:
    <script type="text/javascript">    var fieldName = "cbParamVirtual1"; var fieldName2 = "cbParamVirtual21";    var x1=document.getElementsByName(fieldName); var x2=document.getElementsByName(fieldName2);    x1[0].multiple=true; x2[0].multiple=true; function splitAndParse() { var result = ""; var result2 = ""; var cleanResult = ""; var cleanResult2 = ""; for (var i = 0; i < x1[0].length; i++) { if (x1[0].options[i].selected) { result += "\""+x1[0].options[i].value+"\"" + " OR " ; } } if (x1[0].length > 4) { cleanResult = result.substring(0,(result.length-4)); } document.getElementById("cbParamVirtual2").value = cleanResult; for (var i = 0; i < x2[0].length; i++) { if (x2[0].options[i].selected) { result += "\""+x2[0].options[i].value+"\"" + " OR " ; } }  if (x2[0].length > 4) { cleanResult2 = result2.substring(0,(result2.length-4)); } document.getElementById("cbParamVirtual22").value = cleanResult2; } document.getElementById("caspioform").onsubmit=splitAndParse; </script> I have added the second one, but you can add as many listboxes as you want.
  8. Like
    lmooring reacted to bahar_vm in Enable multiple selection for listbox with virtual fields   
    Here is the solution to implement listbox on search (submission) form as virtual field to function as multi-selection and pass the selected options separated by OR to the results filtering.
    The list box is a virtual field, in our example: "cbParamVirtual1"
    An additional virtual field, in our example "cbParamVirtual2", is needed to store the OR separated string and pass to the next page (results page). You can make this virtual field "hidden" since it is only neccessary for the program and not human use.
    Adjust the script if you have more or less listboxes in your search form. The virtual field ID also should be adjusted accordingly; you can find the ID using Firebug and adjust the X in "cbParamVirtualX".
    The script goes to the footer of the Search/Submission DataPage "Configure Fields" wizard screen. 

    <script type="text/javascript">
       var fieldName = "cbParamVirtual1";

       var x1=document.getElementsByName(fieldName);

    function splitAndParse()
    var result = "";
    var cleanResult = "";
    for (var i = 0; i < x1[0].length; i++) { 
    if (x1[0].options[i].selected) { 
    result += "\""+x1[0].options[i].value+"\"" + " OR " ;

    if (x1[0].length > 4) { cleanResult = result.substring(0,(result.length-4)); }
    document.getElementById("cbParamVirtual2").value = cleanResult;


  9. Like
    lmooring reacted to GoCubbies in Wanted To Share This Third Party Pdf Generator   
    Hello All,
    I just wanted to share this link with everyone in case you are looking to create a quick PDF from a DataPage: http://pdfcrowd.com/save-to-pdf/
    You can simply add this line of code to create a link to generate a PDF:
    <a href="//pdfcrowd.com/url_to_pdf/">Save to PDF</a> Just wanted to share this with everyone!
  10. Like
    lmooring reacted to Jan in Is There An Option For Multiple Choice Fields That Allows Multiple Answers?   
    Hello FreePnyx,
    Welcome to forum!
    You can create a ListBox with multiple choices.
    On Search Page you can open the Advanced tab and check the corresponding checkbox.
    On Submission Form you can use the Java Script code.
    On Single Update Form (and Details page) you can use another Java Script code.
  11. Like
    lmooring reacted to Jan in Using Multiple Javascripts In Submission Forms   
    Hello Liz,
    I think, you can try to write the code of both functions in one, like the following code:
    <SCRIPT LANGUAGE="JavaScript"> function bothFunctions() { var position1 = document.getElementsByName("InsertRecordStore_Email")[0].value; //alert("position1 :" + position1 ); //alert("position1+ :" + document.getElementsByName("InsertRecordStore_Email")[0].value); var position2 = document.getElementsByName("InsertRecordBiller_Email")[0].value; //alert("position2 :" + position2 ); //alert("position2+ :" + document.getElementsByName("InsertRecordBiller_Email")[0].value); var allpositions = position1 + ";" + position2; document.getElementById("cbParamVirtual3").value = allpositions; var v_sDate = document.getElementById("InsertRecordInStoreSFA_Start").value; var v_eDate = document.getElementById("InsertRecordInStoreSFA_End").value; var sDate = new Date(v_sDate); var eDate = new Date(v_eDate); var nDate = new Date(); nDate = Date.now(); var setToday = sDate.getDate() + 1; sDate.setDate(setToday); setToday = eDate.getDate() + 1; eDate.setDate(setToday); if (sDate<nDate)       {          alert("SFA start date must be greater than today");          return false;       }       else         {             if (eDate<sDate)               {                   alert("SFA end date must be greater than SFA start date");                   return false;               }         } }    document.getElementById("caspioform").onsubmit=bothFunctions; </SCRIPT> I hope, it helps.
  12. Like
    lmooring got a reaction from nguyencamvnh in Calculated Grand Total Field In Submission Form   
    I've finally gotten this to work. I had a typo in one of my parameter names and made one of the changes you recommended above. Thanks so much for your help with this!
  13. Like
    lmooring got a reaction from nguyencamvnh in Calculated Grand Total Field In Submission Form   
    I have a submission form that will capture a transaction total, 5 separate invoice totals, and freight charged.
    I would like to create a field that would add all the invoice totals and freight to a grand total.
    Also with a condition that would not allow the form to be submitted if the transaction total and invoice grand total are not equal.
    Is this possible in a submission form?
  14. Like
    lmooring reacted to GoCubbies in Calculated Grand Total Field In Submission Form   
    Are you looking to have this calculation done on submission or on some other type of action before it is submitted?
    Here is an example that I hope gets you started.  As a note, the invoice_total field will need to be a form element text field and hidden using the method found in http://howto.caspio.com/tech-tips-and-articles/common-customizations/how-to-hide-fields-in-datapages/
    <SCRIPT LANGUAGE="JavaScript">

     function calculate()
       /* Retrieve the value of the field Transaction_Total and store in a variable 'v_trans' */
       var v_trans = parseFloat(document.getElementById("InsertRecordTransaction_Total").value);

       /* Retrieve the value of the field Invoice1 and store in a variable 'v_invoice1' */
       var v_invoice1 = parseFloat(document.getElementById("InsertRecordInvoice1").value);

       /* Retrieve the value of the field Invoice2 and store in a variable 'v_invoice2' */
       var v_invoice2 = parseFloat(document.getElementById("InsertRecordInvoice2").value);

       /* Retrieve the value of the field Invoice3 and store in a variable 'v_invoice3' */
       var v_invoice3 = parseFloat(document.getElementById("InsertRecordInvoice3").value);

       /* Retrieve the value of the field Invoice4 and store in a variable 'v_invoice4' */
       var v_invoice4 = parseFloat(document.getElementById("InsertRecordInvoice4").value);

       /* Retrieve the value of the field Invoice5 and store in a variable 'v_invoice5' */
       var v_invoice5 = parseFloat(document.getElementById("InsertRecordInvoice5").value);

       /* Retrieve the value of the field Freight_charged and store in a variable 'v_freight' */
       var v_freight = parseFloat(document.getElementById("InsertRecordFreight_charged").value);

       /* Add all invoices and freight charged and store in variable v_invtotal */
       var v_invtotal= v_invoice1 + v_invoice2 + v_invoice3 + v_invoice4 + v_invoice5 + v_freight;
       /*Check if v_invtotal = v_trans*/
       if ( v_invtotal == v_trans)
            /* Insert a  value of the variable v_invtotal into the DataPage field Invoice_Total */
            document.getElementById("InsertRecordInvoice_Total").value = v_invtotal;
            alert('Transaction Total does not equal values entered. Please re-enter values');

     /* On submitting the webform, the function calculate is executed */

  15. Like
    lmooring reacted to ShWolf in javascript newbie - alphanumeric restriction   
    Try this code:

    <script language="JavaScript"> function checkAlpha1(v_plate){ if(v_plate.value.match(/[^0-9A-Z]|Q|O/)){ alert("Only capital letters or numbers are allowed in this field"); return false; } return true; } function checkAlpha2(v_plate){ if(v_plate.value.match(/[^0-9A-Z]|Q|O/)){ alert("Only capital letters or numbers are allowed in this field"); return false; } return true; } document.getElementById('Submit').onclick = function(){ if(!checkAlpha1(document.getElementById('INSERT_YOUR_FIELD_1_ID_HERE'))) return false; if(!checkAlpha2(document.getElementById('INSERT_YOUR_FIELD_2_ID_HERE'))) return false; } </script> And replace INSERT_YOUR_FIELD_1_ID_HERE and INSERT_YOUR_FIELD_2_ID_HERE with your field ids. Also change criterias in the script for fields, as you need.
    Let me know if this helps.
  16. Like
    lmooring reacted to artdocent in Check That A Date Is Not A Saturday, Sunday Or Monday   
    Figured it out! I modified script I found in another reply to include checking for the day. My script checks that the date is after today, and it is not a Saturday, Sunday or Monday.
     function checkStart() {    var v_sDate = document.getElementById("InsertRecordBooking_Date").value;    var sDate = new Date(v_sDate);    var nDate = new Date();    nDate = Date.now();    var setToday = sDate.getDate() + 1;    sDate.setDate(setToday);        var setDay = sDate.getDay();        if (sDate<nDate)       {          alert("Your requested lesson date is before today.");          return false;       }       else         {             if (setDay == 0 || setDay == 1 || setDay == 2)               {                   alert("Your requested lesson date is a Saturday, Sunday or Monday. Please choose a new date.");                   return false;               }         } }      document.getElementById("caspioform").onsubmit=checkStart;  
  17. Like
    lmooring reacted to MayMusic in Result Page In A Pop Up Window   
    Create your search and result pages in two different pages as described here http://howto.caspio.com/tech-tips-and-articles/parameters/how-to-separate-search-page-and-results-page-into-two-different-webpages/  
    In Configure Fields screen of the search page add Hear/Footer to create your customized button using the code below in the Footer: <input type="button" value="Search" onClick="gotoreport();"> <script language="javascript" type="text/javascript"> function gotoreport() { var URL =  "URL OF THE REPORT PAGE?PARAMNAME=" + document.getElementById('FIELD ID').value + "& PARAMNAME=" + document.getElementById('FIELD ID').value;           newwindow=window.open(URL,'name','height=200,width=150');           if (window.focus) {newwindow.focus()}           return false; } </script> You need to replace URL OF THE REPORT PAGE with URL of the report page and PARAMNAME with the parameter name you are receiving in the report page in Configure Filtering Fields screen as described in the tutorial. Also FIELD ID with the real field ID.
    To hide the original submit button you can either add display:none; to .cbSubmitButton in the style you are using for this page or add a Header to the page and use:
    <style> #Submit{ display:none; } </style>
  18. Like
    lmooring reacted to MayMusic in Validate Based On Date Entered In Submission Form   
    You can try the following code. Make sure to replace 'DATEFIELDNAME' with the real field name in this line: var mydate = document.getElementById('InsertRecordDATEFIELDNAME').value;
    <script>  var TwoWeeksAgo = new Date(); TwoWeeksAgo.setDate(TwoWeeksAgo.getDate() - 14); function chk_date(){ var mydate = document.getElementById('InsertRecordDATEFIELDNAME').value; if ( Date.parse(mydate) <=  TwoWeeksAgo ) { alert('pick a date within the past 14 days'); return false; } } document.getElementById('caspioform').onsubmit=chk_date; </script>
  19. Like
    lmooring reacted to nkamalan in Change data entered into form fields to Uppercase   
    Hello, You can refer to a Caspio field in submission form in this format: "InsertRecordFIELDNAME". In the following code you need to replace FIELDNAME with the real field name you have. You can place it in the footer of the DataPage. 
    <script type="text/javascript"> function upperCase() { var y = document.getElementById("InsertRecordFIELDNAME").value; document.getElementById("InsertRecordFIELDNAME").value = y.toUpperCase(); } document.getElementById("caspioform").onsubmit = upperCase; </script>  Hope that helps. Regards, NKamalan
  • Create New...