Jump to content


Caspio Ninja
  • Content count

  • Joined

  • Last visited

  • Days Won


DefinitelyNot31337 last won the day on August 29

DefinitelyNot31337 had the most liked content!

1 Follower

About DefinitelyNot31337

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hello Cstricker, If I understand you correctly, you wanted to be able to somehow differentiate 'DataPageReady' event from a Form Submission. If this is the case, please know that Caspio also has 'BeforeFormSubmit' event which might help you. The event also can also accept parameters which gives you access to create control statements based on which Form/DataPage AppKey was submitted. Official documentation for AJAX-Loading in Caspio located here. Hope this helps. DN31337
  2. DefinitelyNot31337

    Place API Results into Caspio tables

    Hello Anthony, I tried the API for myself but it seems that the API server is unreacheable. Therefore, I can't test it in my end. Can you send a screenshot of your console? Your Javascript seems to be valid; however, the response of the API or your target Caspio Element may not. Regards, DN31337
  3. DefinitelyNot31337

    Triggering Caspio Rules Programatically

    Hello @TroubleShooter, It seems that Caspio's implementation on Rules only runs when the criteria element fires the input event (for text fields), and NOT when the value has been changed in the DOM. In that case, we can just programatically dispatch that event. See the example below. (I used jQuery to simulate the input event, but this implementation will work on vanillla (plain) Javascript) <script type="text/javascript"> var omega = document.querySelector('#InsertRecordOmega') var event = new Event('input', { 'bubbles': true, 'cancelable': true }); $('#InsertRecordAlpha').on("input", function() { omega.value = this.value; omega.dispatchEvent(event); }); </script> It works for me. I am certain that you can make it work too ;). Happy hacking! Regards, DN31337
  4. DefinitelyNot31337

    Java Script Rule In Update Form

    Hi @edujobs2k18, Please know that you may be able to select DocumentRemarks in more than just one rule (given that it is not a Display Only or Hidden element type) (*For complete list of Limitations, see Action Limitations in this documentation). DocumentRemarks can also be used as a Criteria, even if there is an action that modifies it. Lastly, you may only use the field Once as an action target. A possible reason why you can't select DocumentRemarks as a Criteria is that maybe it's set to be a Hidden or Display Only field. If this is the case, let's just make it a regular Text field, then use JavaScript or CSS to hide or disable that field. A possible reason why you can't target the Document in an action is because it has been used in an existing Rule. If that is the case, just find the existing rule, then add a new criteria to satisfy your condition (or revise your criteria set with converse condition statements). Hope this helps ` DN31337
  5. DefinitelyNot31337

    Validating Phone Number

    Hello @NJConrcs, Sure. It would require custom coding but it's easy to implement. Just do the following. 1.) Go to your DataPage Configuration > Configure Fields. 2.) Add a Header and Footer 3.) Select your Footer and disable HTML Editor in the Advanced Tab. 4.) Paste the code snippet below and replace cbParamVirtual1 to 'InsertRecord' and the name of your field in your DataSource. E.g InsertRecordtelephone <script> var field = 'cbParamVirtual1'; /*Example: var field = 'InsertRecordtelephone'; var field = 'InsertRecordphone'; var field = 'InsertRecordphonenumber'; */ var input = document.querySelector('#' + field); input.maxLength = 14; input.onkeyup = telephize input.onkeydown = telephize function telephize(v_e) { // this.value = this.value.replace( /\D+/g, "" ).replace( /([0-9]{1,3})([0-9]{3})([0-9]{4}$)/gi, "($1) $2-$3" ); //mask numbers (xxx) xxx-xxxx v_e = v_e || window.event; if (v_e.keyCode >= 65 && v_e.keyCode <= 90) { this.value = this.value.substr(0, this.value.length - 1); return false; } else if (v_e.keyCode >= 37 && v_e.keyCode <= 40) { return true; } var v_value = (this.value.replace(/[^\d]/g, '')); if (v_value.length == 7) { this.value = (v_value.substring(0, 3) + "-" + v_value.substring(3, 7)); } else if (v_value.length == 10) { this.value = ("(" + v_value.substring(0, 3) + ") " + v_value.substring(3, 6) + "-" + v_value.substring(6, 10)); }; } document.querySelector('#caspioform').onsubmit = function(e) { e.preventDefault(); if (input.value.length >= 14){ this.submit(); } else { alert('Please input a valid phone number'); input.focus(); } } </script> *Please note that this would not work on DataPages with AJAX Loading enabled, so might need to disable that. More information can be found here. This solution is heavily inspired by this reply. I give full credit to them for the algorithm. I just made a few additions and adjustments. Regards, DN31337
  6. DefinitelyNot31337

    Javascript Not Working

    Hello Dschrepfer, I looked at your script and it seems that what you're trying to achieve here is to just open a link in a new window. I assume that this is a Report DataPage and if that is the case, I believe we can just use an inline javascript function for the onclick attribute of your link. Caspio even has a wizard to set this up easier. In an HTML Block, just highlight your selected text and click on the link icon. The rest, I believe you can figure out with the intuitive wizard. I hope this helps. Kind Regards, DN31337
  7. DefinitelyNot31337

    Generate geolocation from input fields

    I'm so excited. I found a way to make it work even if AJAX Loading is enabled. Luckily, I came across Caspio 13 Impacted Areas and kudos to good guy Caspio making this AJAX Implementation customizable. previous post TL:DR? Follow this instead. To make this work: 1.) Gey an API key here. Enable access to your domains (Website, Caspio URL and Integration URL) (You can see the last two in your Caspio Bridge > Account > Account Settings). 2.) Create/Edit your Submission Form DataPage 3.) Make sure 'Disable AJAX loading' remains UNCHECKED in the DataPage Data Source Section. (If you want otherwise, refer to my previous post instead. This is not cross-compatible as of the moment). 4.) In the Configure Fields section, Add a Header and Footer. 4.1) Select your header, disable the HTML Editor, paste the code block below, replace y0uR_4P1_k3y_H3r3 with your API Key. <script type="text/javascript" src="https://lib.caspio.com/pub/jquery/jquery.js"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=y0uR_4P1_k3y_H3r3"></script> <div id="cbwrapper"> 4.2) Select your footer, disable the HTML Editor, paste the code block below, edit the variables to correspond to your table fields. </div> <span id="error_message"> </span> <script type='text/javascript'> var lat_id = 'InsertRecordlat'; var lng_id = 'InsertRecordlng'; var address_id = 'InsertRecordAddress'; var city_id = 'InsertRecordCity'; var state_id = 'InsertRecordState'; var zip_id = 'InsertRecordZip'; var wrapper_id = 'cbwrapper'; var msg1 = 'Please input a valid address'; if(typeof jQuery != 'undefined'){ var cb_geocoder = cb_geocoder = new google.maps.Geocoder(); document.addEventListener('BeforeFormSubmit', function (event) { event.preventDefault(); var add = $('#'+address_id).val(); var city = $('#'+city_id).val(); var state = $('#'+state_id).val(); var zip = $('#'+zip_id).val(); if(!add || !city || !state || !zip){ alert(msg1); }else{ var full = add +','+city+','+state+' '+zip; cb_geocoder.geocode({address: full}, cbCallBack); } }); }else{ document.getElementById("error_message").innerHTML = "This Datapage require Standard Caspio Deployment for full functionality." ; } function cbCallBack(locResult){ if(locResult != "" && locResult.length>0){ var lat1 = locResult[0].geometry.location.lat(); var lng1 = locResult[0].geometry.location.lng(); lat1 = Number(lat1); lng1 = Number(lng1); $('#'+lat_id).val(lat1); $('#'+lng_id).val(lng1); $('#'+wrapper_id+' form').submit(); }else{ alert(msg1); } } </script> 5.) After saving this, you should be able to make this work. Basic Troubleshooting: > Check your Console by doing a Right-Click > Inspect in your browser. NoApiKeys: You forgot to add your key in the script tag. Google documentation here ReferrerNotAllowed: Check if the domain of your webpage is listed in your Maps API Console (Maps JavaScript API > Credentials > (Key) > Details) There's a bunch of other warnings/errors but I think the first two are the most common and critical. > Feel free to reply to this thread if you encounter problems. Note: This is not a full-fledged fix. I know I skipped adding the WebForm AppKey. Let's just wait for the official Caspio documentation updates. Regards, DN31337
  8. DefinitelyNot31337

    Generate geolocation from input fields

    Hello, Fret not, @TroubleShooter. The Caspio Documentation you have provided seems to be outdated. I've tested this in my end and found out that Google has updated their Maps API. Just to let you know, generating geocodes out of input fields is made possible by a 3rd Party Integration, which is Google Maps API. There are other features of Caspio that rely on 3rd Party Services. As for Google Maps API, Map Mashup on it too. Now to get this to work, we would only need to do a few modifications: 1.) Firstly, get Google Maps API Key in here. (Spoiler. It's not 100% free. It will ask you for a credit card number but won't charge you until you hit a certain usage threshold) Notes: After getting a key, make sure you add your website domain and/or Caspio URL for testing purposes. This AppKey can be used in MapMashup and vice-versa. Meaning, if you have an API Key from Map Mashup, you can use that as well. 2.) Next, you may place the scripts in the Header tag instead. Just a few modifications. Copy-paste this code and replace 7h1sIs4S4mpl3k3y to your API Key. <script type="text/javascript" src="https://lib.caspio.com/pub/jquery/jquery.js"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=7h1sIs4S4mpl3k3y"></script> <div id="cbwrapper"> Notes: Make sure to disable the HTML Editor in the advanced tab of both Header and Footer. This is really important to prevent Caspio from processing our custom markup. 3.) Lastly, disable AJAX Loading. It's a bit complex to explain why but having it enabled causes the Submit button to have dynamic ID, and replaces the standard POST request to a custom XHR function which I cannot find a way to defer. After all these, you should be able to make it work. Please feel free to mention me for feedback about this. Good luck and happy hacking. Cheers, DN31337
  9. I almost forgot, Just to add up, for a better user-experience, you may also make use of JavaScript to do this 'programatically'. Meaning, the web browser will take care of opening a new window and reloading the page for your users. *UPDATE*: You users might be asked to enable pop-ups. They would need to enable that for your site. Just uncheck the enable HTML editor, paste the given code block, and replace [@field:link] to correspond with your link field: <script> window.open('[@field:link]', '_blank', 'resizable=no,status=no,location=no,toolbar=no,menubar=no,fullscreen=no,scrollbars=no,dependent=no'); location.reload(); </script> Hope this helps. Regards, DN31337
  10. Hello @TroubleShooter, Been there before. What I did was to select 'Display a message' instead. Using the rich text editor, I have written a display message and created two links. One, to go to their selected page. Another, to go/return to the Web form. Regards, DN31337
  11. DefinitelyNot31337

    Reload browser upon form submission

    Hello @shaferam, I believe the same functionality is now available as a standard feature as of Caspio 13.0. It's called AJAX Loading. Cool stuff. Links here: https://howto.caspio.com/datapages/ajax-loading/ Hope this helps. Regards, DN31337
  12. DefinitelyNot31337

    Hyperlink in a calculated field

    I just want to add something, though it's a bit off topic. In the solution I provided above, it seems that there's no way we can hide the Calculated Field within the standard features of Caspio. (see sample result below). I just presumed that there are some cases where we might want to hide that Calculated Field. As far as I have investigated, there are no current features of Caspio that can do that so I'll just present some CSS workaround to hide that Calculated Field. Do the following: 1.) Add a header and footer 2.) Click on footer, disable HTML Editor in the Advanced tab; then 3.) Paste the code below and set the calc field index to correspond with the position of your Calculated Field (in my case, 3) <script> // Column Index var CalcFieldIndex = 3; /* Sample usage (asterisks* not included): * * var CalcFieldIndex = 2; * * var CalcFieldIndex = 4; * * var CalcFieldIndex = 7; */ // Do not edit syntax from this point onward!!! // Select the fields in nth column var ff = document.querySelectorAll("table[id*='cbTable'] tr th:nth-child("+ CalcFieldIndex +"), table[id*='cbTable'] tr td:nth-child("+ CalcFieldIndex +")"); // Give 1 second delay to remind devs that we have JS code setTimeout(function(){ //Hide the fields on nth column ff.forEach( function(elem) { elem.style.display = "none"; }); }, 1000); </script> I really hope this helps. DN31337
  13. DefinitelyNot31337

    Hyperlink in a calculated field

    Hello, @NJConrcs. I tested something which seems to be a viable solution. Turns out you can actually use your calculated field in an HTML block. (See image) The default formatting for Calculated Field is Integer, you might want to double check if you want the returned value as a String. After then, you may be able to use that as a hyperlink. Regards, DN31337
  14. DefinitelyNot31337

    Day of the week in table

    A: Yes, I believe you can. I was able to extract the dayOfWeek and put in an Integer field on a Submission Form DataPage. === As for this one... It's strange but I am also getting an error when I tried to put the exact same syntax on a formula field in the table. I think it is best to contact Caspio about this issue. Regards, DN31337
  15. DefinitelyNot31337

    Store Virtual Field Value

    Hello, This howto documentation has instructions exactly how to do that. Please know that it is not necessary to use a virtual field. We can use a regular table field and add custom dropdown-values. Then for our Destination Page URL, you can just reference to your table field instead of a virtual field. The record that will be inserted will have the destination page URL as the value of that field.