Jump to content

Search the Community

Showing results for tags 'javascript'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Caspio Bridge
    • General Questions
    • Caspio JavaScript Solutions
    • Tables, Views and Relationships
    • Import/Export and DataHub
    • DataPages
    • Deployment
    • Security, Authentications, Roles, SAML
    • Styles and Localizations
    • Parameters
    • API and Integration
    • Calculations and aggregations
    • User JavaScript and CSS Discussions

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


MSN


Website URL


ICQ


Yahoo


Skype


Location


Interests

  1. Hi, the below code is used to create comma-delimited text values (in a text255 field) so the user can select multiple values in a list box and save them (separated by commas) in a text field. It's necessary to use this method instead of the Caspio-native 'List' data type because the lookup values need to be dynamic (I wish Caspio would enable this, been waiting FOREVER). This method works great for Details and Update datapages but I need it to also work in a Bulk Edit page. I've tried changing 'EditRecord' to 'BulkEditRecord' but it doesn't work. Does anyone know how to modify this code to work in a Bulk Edit page? This is so the user can select multiple records and update them with multiple selections in a listbox. <script type="text/javascript"> var v_state = "[@field:state]" ; var o_state = document.getElementById("EditRecordstate") ; o_state.multiple = true ; function f_listbox() { if ( v_state.indexOf(",") > 0 ) { for (var i=0 ; i < o_state.options.length; i++ ) { if(o_state[i].value == v_state) { o_state.remove(i); break ; } } var o_st = v_state.split(", ") ; for (var j=0 ; j < o_st.length; j++) { for (var i=0 ; i < o_state.options.length; i++ ) { if(o_st[j]== o_state.options[i].value){ o_state.options[i].selected = true ; break ; } } } } } document.addEventListener('DataPageReady', f_listbox); //You can also use the line below instead of the eventlistener // setTimeout(f_listbox, 20); </script>
  2. Is it possible to count records in a table using javascript instead of a calculated field so the comparison is done right before submission? Or, is there a way to force fields with calculated values to refresh prior to submission? Possibly a custom button that refreshes the fields then submits the form? I've run into a snag using calculated values. Virtual15 is a calculated value and counts how many of a courseID are scheduled for the selected Lesson Date SELECT Count(Lessons_courseID) FROM _v_active_lessons WHERE Lessons_courseID=target.[@field:Lessons_courseID] AND Lesson_Date=target.[@field:Lesson_Date] Virtual8 is also a calculated value that uses CASE WHEN to determine if it's ok to schedule. We can only teach one of each courseID per day. The case statement is checking for other restrictions as well, but they are not dependent on a record count from the active_lessons table. CASE WHEN [@cbParamVirtual15] <> 0 THEN 'This lesson is scheduled for another teacher today. Please select a different day.' ELSE 'ok to schedule' END Then, I use this javascript in the footer to prevent form submission <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function(event) { // prevent form submit if not ok to schedule // if user forget to choose required fields date or time, proceed with submission to generate required field error // alertok variable prevents blank alert box var Input1 = document.querySelector("span[id^='cbParamVirtual8']").innerText; var alertok = 1; if (Input1 == 'ok to schedule' || Input1 == ' ') {} else {event.preventDefault(); if (alertok) { alert(Input1)} alertok = 0; } }); </script> The issue: If the lesson is not already scheduled for a selected date, two users can simultaneously select the same lesson for the same date and both will get the 'ok to schedule'. This allows both users to submit the form and I end up with double signups.
  3. I'd like to make the format of my list report look nicer, how can I do this? Specifically, I'd like to be able to highlight every other row of data (not data cell) and align the labels and the data so that they are directly underneath each other. Edit: Additionally, it would be nice if I could have conditional formatting on the data so that if it is below the goal, the text turns red and if it's at or above the goal the text turns green. The data cells are using calculated fields. Is there a way I can do this conditional formatting in an HTML block that references the calculated field?
  4. I have 12 fields in total - IG1 - IG6, which are dropdown fields and IG1_Qty - IG6_Qty - number input fields, they coincide with each other. The IG fields have 3 possible values - 1, 2, or 3. The Qty field is a number field to state how many of those IGs they want. In Example, the user would select '2' for IG1 and put in 4 for IG1_Qty, showing that they want 4 of the type 2 IGs. Now, the sum field for type 2 IGs would show 4. If we went on to give IG2's value to 2 as well, with a quantity of 1, then the sum field for type 2 IGs would show 5 (4 + 1). Essentially, I want to sum up the selections for the 3 possible IG dropdown values with the quantities selected for each. I was able to create an array with the 6 IG dropdown fields and count how many of each possible values were selected. However, adding in the Quantities for each IG into that number is where I ran into the problem, so I had to change the script entirely. This is my latest try: var ig1v = document.querySelector('select[id^="InsertRecordIG_Sheet_Table_IG1_"]'); //IG1 field - possible values are 1, 2, or 3 var vf1 = document.getElementById("cbParamVirtual22"); //This is where the sum value for IG Type 1 will go var vf2 = document.getElementById("cbParamVirtual23"); //Type 2 var vf3 = document.getElementById("cbParamVirtual21"); //Type 3 var ig1q = document.getElementById("InsertRecordIG_Sheet_Table_IG1_Qty"); //How many of the selected IG type var addNew1 = true; vf1.value = 0; //Setting the value to 0 so that the other calculated fields in the form don't load with an error. //This first eventListener/function is to automatically give 'Qty' a value if the IG dropdown isn't null anymore. This is just to automatically set Qty to 1 instead of blank when the user selects an IG value for the first time - UX document.querySelector('select[id^="InsertRecordIG_Sheet_Table_IG1_"]').addEventListener("change", function () { if (addNew1){ ig1q.value = 1; addNew1 = false; } ig1q.dispatchEvent(new Event('change')); }); //This function is what I am using to count the number of each IG value. If IG = 1, then add the IG1_Qty to the type 1 sum field (vf1), etc. document.getElementById('InsertRecordIG_Sheet_Table_IG1_Qty').addEventListener("change", function calcGroups1(){ if (ig1v.value == 1){ vf1.value = +vf1.value + +ig1q.value; } else if (ig1v.value == 2){ vf2.value = +vf2.value + +ig1q.value; } else if (ig1v.value == 3){ vf3.value = +vf3.value + +ig1q.value; } }); I have 6 of both of those functions for each IG field. Please forgive the ugly JS, I am sure there is a much better way to write this, but I have no clue how. The problems I am now having is that the Sum fields (vf1-vf3) are adding every change. See how the first function in the script sets Qty to 1 when the corresponding IG field is given a value - this is correctly being added to the vf1 totals field. But, if I change the quantity from 1 to another number, it adds it instead of just changing the value. So, when the Qty field is automatically set to 1, and then you change it to 4, the vf1 totals field would show 5 instead of 4. If you changed the 5 to a 4, it would show 9. Also, if the IG type is changed, the totals values are not updated for the previously selected value. Say I have IG1 = 1, Qty = 4. Now VF1 (sums of 1) will show 4. But, if I change IG1 = 2 with the same Qty, now VF2 will show 4, but VF1 will also still show 4. I'm not sure how to go about deleting the value from the previous sum field when the IG type is changed, or when the quantity is changed. I apologize for this being so confusing, but it is making my head turn into mush and I could use any of the help I can get.
  5. I'd like to have a colored table that can highlight past due items. This is the code I have in an HTML block that highlights the row of past due dates and turns the font color red. <div id="visi[@field:lines_Line_Number]">[@field:dates_Customer_Expected_Date*]</div> <script> var isi = document.getElementById("visi[@field:lines_Line_Number]"); if('[@field:dates_Customer_Expected_Date*]' < '[@cbTimestamp*]'){ isi.parentNode.parentNode.style.backgroundColor = 'yellow'; //background color isi.style.color="red"; //font color } else{ isi.parentNode.parentNode.style.backgroundColor = '#NoColor'; } </script> Meanwhile, this is part of the color I have in my header that turns the column headers and background different colors. style type="text/css">[class*=cbResultSetHeaderCell]:nth-child(1) { background: #3377FF !important; } td[class*="cbResultSetData"]:nth-of-type(1){ background-color: #4D88FF !important; } [class*=cbResultSetHeaderCell]:nth-child(2) { background: #1966FF !important; } td[class*="cbResultSetData"]:nth-of-type(2){ background-color: #3377FF !important; } [class*=cbResultSetHeaderCell]:nth-child(3) { background: #0055FF !important; } td[class*="cbResultSetData"]:nth-of-type(3){ background-color: #1966FF !important; } [class*=cbResultSetHeaderCell]:nth-child(4) { background: #cc0000 !important; } td[class*="cbResultSetData"]:nth-of-type(4){ background-color: #E60000 !important; } [class*=cbResultSetHeaderCell]:nth-child(5) { background: #cc0000 !important; } Here is the result of this code: Clearly, the highlight works as it applies to uncolored columns. How do I alter the code so that the highlight is prioritized and will override any existing color?
  6. I want to change the color of an entire column. No conditionals necessary.
  7. I'd like to have different colors for some of my column headers so that I can group them together. How can I do this?
  8. Hi, Part of my app is a chat/messaging module that enables users in the same account (it's a SaaS app where each customer might have multiple authenticated users in the same account) to 'chat' or message each other. Everything is good on it except I need to figure out how to show a popup notification to the user who a message is directed to, instantaneously, so they know they have one. I don't mean using the email or text message triggers (already have that enabled) but showing a small 'you have a new message' message in the lower right of the web page the app is hosted on. I've used sliding panels, fancybox, and straight popups in other areas so I imagine I can configure one of those methods to show the notification and new message content. The problem I'm having is, how do you trigger a function to open a notification popup/panel in another user's account, on a different computer entirely? So when User1 submits a new message directed to User2, User2 will get an instant notification in their own browser? I imagine it's some sort of listener setup but don't really know how it would work. If anyone has any suggestions that'd be great!
  9. Hi, I'm trying to use the code below in the footer of a tabular report results section for the 'Inline Add New Record' can use it. The js is code to get the user's computer date/time (not the localization or CB system) and put it in a date/time field. I use this code in submission forms with no issues but don't know how to reference it correctly for a tabular inline add new record. If someone knows how to mod this I'd really appreciate it. <SCRIPT LANGUAGE="JavaScript"> /* Declaration and initialization */ Stamp = new Date(); var v_TimeStamp; Hours = Stamp.getHours() Mins = Stamp.getMinutes(); Secs = Stamp.getSeconds(); /* Attach a prefix with digit '0' if the minutes is less than 10. */ if (Mins < 10) { Mins = "0" + Mins; } /* Construct the value of the v_TimeStamp variable in the format m/d/yyyy hh:mm */ v_TimeStamp=('' + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+Stamp.getFullYear() + ' ' + Hours + ":" + Mins + ":" + Secs); document.getElementById("InsertRecordComments_Actual_Submission_Date").value=v_TimeStamp; </SCRIPT> EDIT: just found the solution right after posting this. In case anyone needs it, tabular inline add uses 'InlineAdd' instead of 'InsertRecord'. Wish everything was so easy!
  10. I have a specific form that creates a new entry in a table, and I need it to NOT create an entry if one already exists, instead just go to a diferent page altogether. I can prevent the duplicate entry by making a field unique, the form submit will fail and no new entry will be made. Problem I have is that the initial page that makes the table entry auto-submits when you open it (which is by design). If it successfully completes the table entry, it then auto-loads the next datapage, however if it fails the submit it actually reloads the entire page which in turn tries to re-submit the document and gets caught in a loop of submitting failures forever. What can I do to detect the failure and then re-direct to a different data page? I tried the below code to attempt to trap it, but it does not work... <script> var v_elements = document.getElementsByTagName("p"); for (var i = 0; i < v_elements.length; i++) { if (v_elements.className == "cbFormError") { location. href = "https://c1acyXXX.caspio.com/dp/48c0900099f0e199ea0043c3XXXX"; } } </script>
  11. I have been pounding my head against a wall on this one. I need to do data validation for two fields in a tabular report data page in two different scenarios. I have been successfully using the following code to validate one field: <script> var nameOfField = "InlineAddWhole_Value_Perc_Split_to_Agent"; document.addEventListener('DOMSubtreeModified', function(){ if(document.getElementsByName(nameOfField)[0]) { document.getElementsByName(nameOfField)[0].addEventListener('change', function(){ var cash= document.getElementsByName(nameOfField)[0].value; if(isNaN(cash)) { alert("You have entered an invalid number in the Split to Agent field. Value must be numeric whole value decimal. Do not include letters or symbols."); document.getElementsByName(nameOfField)[0].value=""; document.getElementsByName(nameOfField)[0].focus(); } else if((cash) < 0) { alert("You have entered an invalid number in the Split to Agent field. Value cannot be a negative amount."); document.getElementsByName(nameOfField)[0].value="0"; document.getElementsByName(nameOfField)[0].focus(); } else if((cash) > 100) { alert("You have entered an invalid number in the Split to Agent field. Percentage value must be entered as a whole value percentage. i.e. 100% = 100 and 50% = 50"); document.getElementsByName(nameOfField)[0].value="100"; document.getElementsByName(nameOfField)[0].focus(); } }); } }); </script> 1st scenario - How do I validate two different fields independently? Basically field "split to Agent" must be between 0 & 100 and field "Agent ID" must be non-zero. 2nd scenario - How do I validate two different fields dependently? IF field "split to Agent" is less than 100 THEN field "Agent ID" must be non-zero. The main issue that I am running into is that I cannot figure out how to do an event listener for more than 1 field at a time. No matter how I have tried to implement it, I can't. I would appreciate any help that I can get here. Is that possible to implement? Is there any way to implement this? Thank you in advanced! Tyler
  12. I've got a dropdown menu that I need the links to run a function in order to open a new window (in '_self') and then change that new window's iframe source (same domain as parent). I'm calling the function from a linked js file that runs the code correctly but ONLY if the new window is opened in a new tab. I've seen a lot of posts about how to transfer the js function to the new window but none of them if it's opened '_self'. Here's what I have so far (It's on a test server right now, hence the 127 address for the js file): function newWindow() { var win = window.open('projects/project-dashboard','_self'); win.document.head.innerHTML = '<title></title></head>'; win.document.body.innerHTML = '<body></body>'; var script = document.createElement('script'); script.type = "text/javascript"; script.src = 'http://127.0.0.1:9090/js/projnav.js'; win.document.head.appendChild(script); } The file js/projnav.js has a function that needs to run in the new window, and it does but only when opened in '_blank'. Does anyone know how to modify this to run the projnav.js function if the new window is opened in the same tab? Any help with this would be really appreciated!
  13. Hi, I have a Details (or single record update, haven't decided yet) form that, when updated, I need to open a fancybox that brings up another web page. The Details/Single-Rec-Update form would ideally be set to 'Same Form' for destination but I think I need to use Message in order to put code in. The below code is taken from what I'd been using with a button to open the fancybox but with the data-href put in (whereas the button would put that in before). Does anyone know what mods need to be done to this code for it to work (open a fancy box with a new web page after submission/update)? <script> var width = 450; var v_data-href="../shortcuts/universal-item-search"; var v_href= $(el).attr('href'); if (v_href=="#") { v_href=$(el).attr('v_data-href'); } if($(el).attr('data-width')){ width = $(el).attr('data-width'); } $(el).fancybox({ closeBtn:false, openEffect : 'none', closeEffect : 'none', modal:true, type:'iframe', autoSize:true, width:width, //href:$(el).attr('href') href:v_href }); </script>
  14. Unfortunately, this cannot be done with a table trigger because this table is updated by other datapages as well. I have a report that searches training dates, lists providers, and sets an indicator based on the fact that the provider took a training. The indicator can be set to yes for each provider with a bulk edit. An indicator date needs to be added when the indicator is set to yes. If this date is not added, I want it to default to the training date. It seems like it would be easy but I can't get the indicator date to save the training date value in the bulk edit if it is blank. There should be a way to take the training date from the results page, set the indicator date equal to that, and then if the user doesn't change that when setting the indicator in the bulk edit to yes/checked, it would save that training date in that indicator date field. I looked into doing this with a trigger, loading the training date into the indicator date field on load, using a placeholder, and JavaScript, but I can't get the value to save. If anyone has advice on how to do this, I would appreciate knowing about it. Thanks.
  15. Hello, I've got a Single Record Update datapage that has a number of cascading dropdowns. I need to check 2 values (one a table's field and the other a virtual field) and if they're not equal then make the cascading drop down values null or blank. I can get this to work for a regular text field but not cascading dropdowns. The code so far is: <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { var x = document.querySelector('[name*=cbParamVirtual1]').value; var y = document.getElementById("EditRecordProjectID").value; var xclear = ""; if (x !== y){ document.getElementById("EditRecordKeyword").value = xclear; document.getElementsByName("EditRecordArea")[0].value = xclear; } }); </script> The cascading dropdown field is 'Area' and its parent is Virtual1 (Virtual1 gets an external integer parameter). It holds a text value and has a lookup table and a custom option of 'none selected' (blank value). The text field 'Keyword' will update to blank if Virtual1 and ProjectID are not equal, but the 'Area' cascading dropdown won't. Does anyone know how to update the cascading dropdown value to blank/null if ProjectID and Virtual1 are not equal?
  16. Hi, I took some code from one of Caspio's demo apps (an appointment scheduler) to create a Time Picker on a Submission form. This works great, allowing far more detailed calendar scheduling than just using the date without a time. The issue is when the user needs to edit the date/time from the Calendar, in Details view. The code doesn't work in this case. I've changed the 'InsertRecord' part to 'EditRecord' but that doesn't seem to make a difference. Is there some difference to calling the code from the Update button vs a Submission button? Any help would be greatly appreciated. Below is the process and code in the Submission form's footer. I need to modify it to work in a Calendar's Detail view: a) the user selects a Date from the calendar popup for field Virtual6 (set to Text). b) the user then clicks this link in an html block to open the Time Picker: <input type="time" name="time" class="timeClass" id="timepicker"/> c) on Submission the code below runs to combine the date from Virtual6 and the time from the Time Picker into the actual Date/Time field TasksTimeine_CalDate. ****I need this code to work on a Calendar's Detail View Update. <script type="text/javascript"> var datefield=document.createElement("input"); datefield.setAttribute("type", "time"); if (datefield.type!="time") { //if browser doesn't support input type="time" document.addEventListener("DataPageReady", function () { $('#timepicker').timepicker({ timeFormat: 'HH:mm', interval: 1, minTime: '00:00', maxTime: '23:59', defaultTime: '6', startTime: '00:00', dynamic: false, dropdown: true, scrollbar: true, timepicker: true, datepicker: false, stepHour: 1, stepMinute: 1, timeInput: true, showHour: true, showMinute: true, pickerTimeFormat: 'hh:mm tt' }); }); } document.getElementsByName('Submit')[0].onmouseover = function(){ var date = document.getElementById('cbParamVirtual6').value; if(date == "") { date = "1/1/2011"; } var ampm = document.getElementById('timepicker').value; document.getElementById('InsertRecordTasksTimeline_CalDate').value = date + " " + ampm; }; </script>
  17. I am trying to run the following JS to make sure the value in one field has been entered in decimal form, but I can't get it to work. I have tried multiple iterations/adaptions of suggestions I have found on the forums. Any help would be appreciated. Thank you! <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function () { event.preventDefault(); var a = document.getElementsByName("InsertRecordSplit_To_Agent"); if (a[0].value <=0 || a[0].value >1) { alert('Split to Agent value is not in the correct range. Please enter split percentage in decimal form.'); } else { document.forms["caspioform"].submit(); } }); </script> Forum posts/pages I have tried to use for adaptions/reference https://howto.caspio.com/datapages/ajax-loading/
  18. Hello, I'm trying to reference a field, in a Details datapage, that is a cascading dropdown (the field is a text field called 'Area'). I need to disable it conditionally using javascript (I've found that when there are a lot of Rules it significantly slows the datapage loading compared to using js, so I need to use js to do this). I've been able to do this no problem with regular text fields and dropdowns but can't get it to read the cascading dropdown. I've been trying to use something like: var v_area = document.getElementsByName("EditRecordArea")[0]; along with the disable code in an if/then clause v_area.disabled=true; Does anyone know how to alter the above to be able to use it in js? Many thanks!
  19. Hopefully someone can look at this particular scenario and show how to open the popup in modal with an overlay background. A couple issues: I cannot use an iframe for the popup content (passing parameters to a Caspio datapage, which doesn't work smoothly via iframe). Nor can I use a div for the content (because it's an entirely different datapage) that's in the same datapage as the button that creates the popup. So I need to open an entirely new url in a window, as a popup. The new url (web page) will have a datapage embedded. The code below does this fine but I also need it to make the popup modal (with an overlay background around it, if possible). Does anyone know how to tweak this code to make the new window popup modal? Thanks for any help! Here's the button that is in an html block in a tabular datapage: <button class="btnew" type="button" onclick=" edititem('https://edit-item?ItemID=[@field:ItemID]', 'web', 1200, 900);"><span><i class="fa fa-pencil" aria-hidden="true"></i> Edit</span></button> And here is the js that is in the same html block that creates the actual popup with the relevant web page. This works well, I just need to make the popup modal. function edititem(myURL, title, myWidth, myHeight) { var left = (screen.width - myWidth) / 2; var top = (screen.height - myHeight) / 4; var myWindow = window.open(myURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + myWidth + ', height=' + myHeight + ', top=' + top + ', left=' + left); }
  20. Hi, I was wondering how can we add a default value to the "Sort By" dropdown menu. I am not seeing any options through the menus.
  21. Hello, I have a field that normally would be a cascading radio button whose value is dependent on the selection of another field's dropdown value (the parent). However, I need the user to be able to over-ride the cascaded value occasionally. You can't do this normally so I'm trying to use js to do it. There is a text field set to Dropdown, called 'SalesCode.' A Virtual field (Virtual 18) is set to Cascading Text Field so it can receive a value when 'SalesCode' (the parent) is updated. The text field called 'Taxable' is the one I need to update. It's set to a Radio Button with 2 custom choices ('tax' or 'non'). The code I think I need is 'on change' for the SalesCode drop down field. Meaning when the user updates the SalesCode value, it updates Virtual18 (cascaded) and then the code takes the value of Virtual18 and puts in in the Taxable field's Radio Button value (the value in Virtual18 will always be either 'tax' or 'non' so it corresponds with the custom choices in Taxable). If the user wants to override that Taxable value they can change the radio button choice. The code below is something like I think I need but I can't get it to work, any help would be really great! <script> $("#InsertRecordSalesCode").change(function(){ var v_tax = document.getElementsByName("cbParamVirtual18")[0].value; document.getElementsByName("InsertRecordTaxable")[0].value = v_tax; }); </script>
  22. I am running a calendar data page which shows different code for service types in a day. Would like the all elements of the service type background to be certain colors. I found this link in the forum but is not working.
  23. I am trying to pass fields with special characters such as a Hash(#) over query string? I am new to Javascript, but I copied the Javascript from the answer below, and it works fine on the first link of the grid, but all the rest of the links have the parent URL and none of the data. It is building the parameters properly for the first link. I inspected the broken link and I found: Do I need a loop? or do I need to refer to the links I am trying to encode a different way than document.querySelector(`#${link_id}`).href = `${base_url}?${params.join("&")}` Is there a better way to build the links? I have 17 fields that I am adding to the array to build the links. I would appreciate any help
  24. Hello, I'm using some code in the Destination section of a submission datapage, deployed in a popup, to update a dropdown field in another datapage. I can get it to work if the dropdown field is a simple text field (store and display the same field) but am having issues when the dropdown is set to store the Unique ID (integer field) but display a different text field. The purpose of the popup is for the user, when creating an inventory item on one datapage, to be able to add a new 'supplier' for it on the fly in another datapage. When the new 'supplier' is submitted, it's ID value goes to the 'supplier' field dropdown on the original datapage and is added to the available lookup choices. The problem is that this code will put the new Unique ID (the SupplierID) in the the dropdown's 'display' so the user sees the ID number instead of the supplier name they typed in on the popup datapage. That new supplier name (text field) is what I need to 'display' in the drop down field BUT use the uniqueID as the 'stored' value. Also, I normally would use a trigger and a field for quick entry (the Supplier's table is different than the Inventory Items table) that could do all this behind the scenes. However, that table is locked by Caspio because of other backend triggers so I have to do this with datapages. Here's the code I'm using. Again, I need to 'display' the Supplier_Name (text255) value but 'store' the SupplierID (integer) when it's sent to the dropdown in the other datapage. Any help would be really appreciated! <script> window.close(); //Replace the FieldName with the Submission form FieldName(parameter name passed when you checked “on exit”. var element_value='[@InsertRecordSupplierID]' var new_item = window.opener.document.createElement("option"); new_item.text=element_value; new_item.value=element_value; // Add new item to the dropdown try { //Replace the FieldName with the Original DataPage dropdown FieldName window.opener.document.getElementsByName("InsertRecordSupplierID")[0].options.add(new_item, null); } catch(ex) { //Replace the FieldName with the Original DataPage dropdown FieldName window.opener.document.getElementsByName("InsertRecordSupplierID")[0].options.add(new_item); } </script>
  25. Hello, On a Details form, I have a text64000 field (uses Rich Text editor toolbar) to store an address value. This value can come from 3 different places, with different values from each, so, depending on which source the user chooses, I hide/show and use a virtual check box to run javascript on change, to paste a value from another virtual field into the text64000 field. <script> $("[name='cbParamVirtual19']").change(function(){ f_copy_print_address('cbParamVirtual22', 'cke_EditRecordItems_ShipAddress'); var v2 = document.getElementsByName("cbParamVirtual22")[0].value; }); $("[name='cbParamVirtual20']").change(function(){ f_copy_print_address('cbParamVirtual23', 'cke_EditRecordItems_ShipAddress'); var v2 = document.getElementsByName("cbParamVirtual23")[0].value; }); $("[name='cbParamVirtual21']").change(function(){ f_copy_print_address('cbParamVirtual24', 'cke_EditRecordItems_ShipAddress'); var v2 = document.getElementsByName("cbParamVirtual24")[0].value; }); </script> This will take the value from Virtual 22, 23, 24 (they are cascading virtual fields, hence the GetElementsByName) respectively and put it into the Items_ShipAddress field. This works fine in terms of getting the address value to show up in the Items_ShipAddress field. The problem is that when Updated this value is not saved (even though you can see it in the Items_ShipAddress field) UNLESS the user clicks into the Items_ShipAddress field and manually types in at least 1 letter (meaning they have to manually edit the field to save the value, the value the js puts in somehow doesn't 'stick'). I tried saving as a variable the values from Virtual 22, 23, 24 when they're generated (as you can see by that line of code above) and then using that variable to 'save' to the Items_ShipAddress field before Submit (code below). But it's not using the variable if/when the user changes the choice of which virtual checkbox to use (the on Change code). This is the code for before submit: <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function (event) { document.getElementById("EditRecordItems_ShipAddress").value = v2; }); </script> Any help would be really appreciated (I've tried using calculated values but haven't been able to get it to work for a number of reasons- I'd really just like the js to work).
×
×
  • Create New...