Jump to content


Caspio Ninja
  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Elderberg

  1. Just leaving this here ... <script> document.addEventListener('DataPageReady', function(event) { function hideControlsForPerson() { var table = typeof document.getElementsByClassName("cbResultSetTable" + event.detail.uniqueSuffix)[0] == "undefined" ? document.getElementsByClassName("cbResultSetTable")[0] : document.getElementsByClassName("cbResultSetTable" + event.detail.uniqueSuffix)[0]; // Find the index of the last column, which happens to be the inline edit/delete var total_num_columns = table.rows[0].cells.length; var controlsColumnIndex = total_num_columns - 1; //position of the column with inline edit/delete // Find the index position of the column by searching the column's label row = table.rows[0]; var i; var KeyColumnIndex; for (i = 0; i < total_num_columns; i++) { if (row.cells[i].textContent == 'Label_of_Target_Field') { KeyColumnIndex = i; i = total_num_columns; // this is essentially to exit the loop } } // Iterating through rows and hiding Content for (var i = 1, row; row = table.rows[i]; i++) { if (row.cells.length > KeyColumnIndex && row.cells[KeyColumnIndex].textContent !== '[@authfield:Name]') { row.cells[controlsColumnIndex].style = "display:none;" } } } hideControlsForPerson( ); }); </script> Note: " row.cells.length > KeyColumnIndex " was added to the if statement to protect against an uncaught TypeError that happens if using a date rollup or other field grouping.
  2. Hi There, Would it be possible to update this to automatically find the Index for "nameColumnIndex" and "controlsColumnIndex" based on the name of those fields by counting until some condition is met? This would help when we add change the column positions later on so as not to break the code. Thanks in advance
  3. Did some reading and testing.. my solution, isn't perfect, it just submits the last form on a page with multiple forms. Note that this counts ALL forms and not just forms with "caspioform" as the ID. var x = document.forms; x[x.length-1].submit();
  4. I've isolated the issue to when i have 2 data pages.. with the update page being the second one. I think the document.forms["caspioform"].submit() is submitting the first datapage (which is a HTML page). Any ideas.
  5. I've inserted the following into an html block: <input type="button" name="Mod0CancelRecord1" value="CANCEL" class="cbBackButton"> And then in the footer i've inserted: document.getElementsByName('Mod0CancelRecord1')[0].onclick = function(){ if (confirm("Close Window?")) { window.close(); } }; but unfortunately i've discovered : Any ideas or suggestions are welcome
  6. Hi, i've selected Custom option using Totals and Aggregation.. how do I use the Custom option to do summation?
  7. Excellent. thank you. I will give this a try next time. I ended up renaming my fields, it wasn't as time consuming as I thought, but will look into what you've shared in future scenarios.
  8. Hi, See below the code which i've used on a web form submission successfully. I've tested this on the Details page, it seems to work, however, the changes made on the Details page don't get written to the database table. Any advise welcome.. <script> // PREVENT SUBMIT UNLESS VALIDATED document.addEventListener('BeforeFormSubmit', function(event) { event.preventDefault(); //do something before submitting update document.forms["caspioform"].submit(); }); </script>
  9. www.example.com/datapage.asp?cid=D4ITUH2C Is it possible to directly reference the cid value using Javascript?
  10. For benefit of others, the following code works better: // PREVENT SUBMIT UNLESS VALIDATED document.addEventListener('BeforeFormSubmit', function(event) { if (some_condition) { //result if condition is met } else { event.preventDefault() } });
  11. I resolved a way to trigger an onchange event on Field1 programmatically. Once the onchange event is triggered the cascading dropdown refreshes properly. var e = document.querySelector("[id*=cbParamVirtual40]"); e.dispatchEvent(new Event('change'));
  12. I've isolated it to the javascript below which I've used successfully in other datapages. I've stripped away my code and run the form with the below code verbatim. (i.e. the if statement i changed the condition to be "1") and ran the code and experienced the weird issue. I'm totally stumped. <script type="text/javascript"> // PREVENT SUBMIT UNLESS VALIDATED document.addEventListener('BeforeFormSubmit', function(event) { event.preventDefault(); // checks validation rules, only submits if all rules are validated successfully. if (1) { document.forms["caspioform"].submit(); } }); </script>
  13. Upon successful submission I have a message displaying "Your record was successfully updated." However, for some reason now the submission form is repeated below this after successful submission. I notice after the submission the URL has this: ?appSession=8RB87A2G927E83NL92A4 ... I'm not sure why this appSession key is appended to the URL but it seems to be causing the issue. Does anyone have any idea what's going on or tips on where I should start troubleshooting? I tried to check a few places when I edit the datapage but didnt see anything out of the ordinary.
  14. I'm having trouble getting a cascading dropdown to refresh programatically : I have two fields: Field1 (dropdown) and Field2(cascading dropdown), when the page loads I can using javascript set the value of Field1, but the corresponding Field2 does not recalculate. its always stuck filtering off the first item in the Field1 dropdown.
  15. FYI, for benefit of others with similar problem that want to use a single page with the search criteria displayed above the Results. //insert script below into Footer of "Configure Search Fields" <script> document.addEventListener('DataPageReady', function (event) { // Create a new Virtual Field (in my case cbParamVirtual1) for user to enter the search parameter. // The below code will execute when the user updates the Virtual Field and then stamp it into multiple fields. var x10 = document.querySelector('[id=cbParamVirtual1]'); x10.onchange = function() { document.getElementById('Value1_1').value = document.getElementById('cbParamVirtual1').value; document.getElementById('Value2_1').value = document.getElementById('cbParamVirtual1').value; document.getElementById('Value3_1').value = document.getElementById('cbParamVirtual1').value; } }) </script> Also you'll need to edit items under the Logic tab as follows: After you test, you can hide the fields: Value1_1, Value2_1, etc
  16. Thanks Vitaliksssss. however, is there a way to capture and reference the alphanumeric key that's appended? I have a use case where i'm using the following fields in my table: - fno1_paytype - fno1_Start_Time - fno1_End_Time - fno1 I'm having trouble accessing fno1 because document.querySelector("[id*=InsertRecordfno1_]"); isn't catching the correct field Ultimately I may have to rename fields, but since I have a lot of javascript, as well as multiple datapages already built and working which references the above table fields, renaming would be a worst case scenario.
  17. Inspecting the webpage I see that caspio in some cases appends an alphanumeric code to a virtual field ex: cbParamVirtual23_5cc2f7c259e4b5 I've read and used fairly successfully the following to reference the value: document.querySelector('[id*=cbParamVirtual23]'); My question: is there a more explicit way to reference this virtual field? Reason being the asterisk is a wildcard and it gets messy when referencing cbParamVirtual2 if there is a cbParamVirtual23 present prior.
  18. Hi, this might be a bit advanced.. If i'm using a SubmissionForm Datapage i would be able to use the following to retrieve the value of a field: var Flag = document.getElementById('UpdateRecordYesNo').value; but i'm using a Tabular Report Datapage paired with a HTML Block . I'm trying to get the value of [@field:YesNo] and assign it to a variable called Flag. Can someone help me with the correct syntax to reference a field associated with the current row of a tabular datapage? <div id="mydiv[@field:CMP_ID2]"> </div> <SCRIPT LANGUAGE="JavaScript"> var Flag = [@field:YesNo^] if ( Flag = 1){ document.getElementById("mydiv[@field:CMP_ID2]").innerHTML = "X" ; } else{ document.getElementById("mydiv[@field:CMP_ID2]").innerHTML = "Y" ; } </SCRIPT>
  19. Hi There,I'm using a Chart Datapage and in the search footer I have the following which i'm testing something weird.<script>document.addEventListener('DataPageReady', function (event) {alert("Hello World");});</script>The hello world executes 3 times upon loading.. Can someone advise i I would be able to limit the execution to run just once?
  20. Solution Involves 2 Parts: Part 1: You need to use setTimeout() method to delay the code such that it runs AFTER the calculated fields get computed. See https://www.w3schools.com/jsref/met_win_settimeout.asp Part 2: You need to reference calculated fields using the document.getElementsByName with index 0 instead of by ID, this is because caspio adds some alphanumeric codes after the Virtual Parameters ID when its set to a Calculated Field. See Code: var x = document.getElementsByName("cbParamVirtual27")[0].value; document.getElementById("ElderbergHTMLBlock1").innerHTML = x;
  21. hmm, I think my code is running before the calculated field executes based on some tests I did. Is there a way to wait until Virtual Fields are calculated? I tried this unsuccessfully: document.addEventListener('DataPageReady', function (event) { });
  22. I'm wondering if its possible to run an SQL Select Statement within footer instead of as a calculated field.
  23. Please bear with me as i try to unfold this. I have a submission datapage with a Virtual Field (Virtual23) where as a Calculated Field i'm using a SELECT statement to fetch what I need correctly. This is successful. Where i'm struggling is how to reference this value in javascript. I'm trying to store the value in a varable ... I've tried this: var x = document.getElementById("cbParamVirtual23").value; and it doesn't seem to work. I'm assuming the value fetched by the SELECT statement should return a string. I've tried the below code to test if it works, but it fails. document.getElementById("ElderbergHTMLBlock1").innerHTML = x; document.getElementById("ElderbergHTMLBlock1").innerHTML = x.toString();
  24. I realize the Task creates the dates as a Date Object.. i think i need it to be saved as a String. I was unsuccessful in my attempt to modify your Task. Can you advise if this is possible?
  25. Hey Vitalikssssss, I implemented your suggestion using a Dropdown box. Previously I had a VirtualField configured as a TextField with calendar pop up enabled. Below are two lines of code which i used previously when the field was a TextField. Can you advise how I would 1.) assign v_DateOnlyStamp as a value to the dropbox 2.) pass the selected value of the dropbox to a variable. // Assign Current Date document.getElementById('cbParamVirtual1').value=v_DateOnlyStamp; // pass value to variable var date = document.getElementById('cbParamVirtual1').value;
  • Create New...