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. Hello. I would like to concatenate two text fields (both foreign keys) and populate a third text field in the same table with the concatenated value when submitting a DataPage. I understand how to do this when I am concatenating the stored value of the fields, but I would like to concatenate the display values of the two lookup fields, not their stored values. Please advise.
  2. So this is something that has been addressed a couple of different times but not of the Javascript solutions work for me. I have an update page that has 3 listboxes with multi-select enabled. I need the update page to display the multiple selections in the listbox separately and not in one long sentence separated by commas. Here are two of the different scripts I have tried to use, neither has worked. First: <script> // Function for selecting corresponding elements from the list box. function select_ (){ // get listbox element var o_els = new Array("EditRecordStatus","EditRecordMarket_Sector","EditRecordDivisions"); for (var k=0; k< o_els.length; k++ ) { var o_el = document.getElementById(o_els[k]); // Enable multiselect for listbox o_el.multiple="multiple"; // get listbox length var len = o_el.options.length; // get selected element var selected = o_el.options[len-1].value; // verify if selected element contains comas, if yes, do the following if (selected.indexOf(",") != -1 ){ // Split selected option into array var m_array = new Array();m_array=selected.split (","); // Delete last option from the listbox o_el.options.remove(len-1); // Go through listbox and select each option, if it is present in array for( var i=0; i< m_array.length; i++ ){for( var j=0; j< len-1; j++ ){ // Trim spaces while comparing elements from array and listbox if( m_array.replace(/^s+|s+$/g, '') == o_el.options[j].value ){ o_el.options[j].selected = "selected"; } } } } } } // call select_ funtion when details page is loaded window.onload = select_; </script> Second (On this one the 3rd Listbox works but the other two do not): <script type="text/javascript"> var v_state = "[@field:Status]" ; var o_state = document.getElementById("EditRecordStatus") ; 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.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.value){ o_state.options.selected = true ; break ; } } } } } window.onload = f_listbox ; </script> <script type="text/javascript"> var v_state = "[@field:Market_Sector]" ; var o_state = document.getElementById("EditRecordMarket_Sector") ; o_state.multiple = true ; function f_listbox2() { if ( v_state.indexOf(",") > 0 ) { for (var i=0 ; i < o_state.options.length; i++ ) { if(o_state.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.value){ o_state.options.selected = true ; break ; } } } } } window.onload = f_listbox2 ; </script> <script type="text/javascript"> var v_state = "[@field:Divisions]" ; var o_state = document.getElementById("EditRecordDivisions") ; o_state.multiple = true ; function f_listbox3() { if ( v_state.indexOf(",") > 0 ) { for (var i=0 ; i < o_state.options.length; i++ ) { if(o_state.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.value){ o_state.options.selected = true ; break ; } } } } } window.onload = f_listbox3 ; </script> Thank you for your help!
  3. I have a datapage submission form which I need to make a counter based on an external parameter. Virtual2 receives an external parameter (authorization field) on loading. This works fine. Goods is a hidden field in the datapage. An updated value should be saved in this field on submission. The script goes like below, but it doesn’t work. Actually I cant get goods to receive and store any value. Please advise on solutions. <SCRIPT LANGUAGE="JavaScript"> Function calculate() { var number = parsefloat(document.getElementsByName('cbParamVirtual2')[0].value); var newnumber = number + 1; document.getElementById('InsertRecordgoods').value = newnumber; } document.getElementById("caspioform").onsubmit= calculate; </SCRIPT>
  4. We have a number of processes which were originally built to update single records and used javascript to test for certain conditions and post values into fields dependiong upon the results. As an example, if an agent clicks the JS button to mark a job as compete, the script caclulates the current time plus 10 minutes and posts that to a field. When looking at the "live" situation on screen, the controller screen filters for jobs that are either no marked as complete, or where the Completed Time + 10 mins field value is after no (i.e. a job will be shown if completed within the last 9 minutes). This process works fine when an agent is only dealing with a single job but if he is processing a bulk edit of multiple jobs, the script fails to operate. Is it possible to run javascripts within the bulk edit popup window and if so, is there some code we need to enter to ensure that each record selected for bulk edit receives the same correct data? Any helkp woud be appreciated - even if it just tells me that it cannot be done so I can stop wasting my time trying. Thanks
  5. <script type="text/javascript"> function calculate(){ var pm1 = document.getElementById("cbParamVirtual3").value; var pm2 = document.getElementById("cbParamVirtual8").value; var pm3 = document.getElementById("cbParamVirtual13").value; var pm4 = document.getElementById("cbParamVirtual18").value; var pm5 = document.getElementById("cbParamVirtual23").value; var pm6 = document.getElementById("cbParamVirtual28").value; document.getElementById("EditRecordTotal").value = pm1 + pm2 + pm3 + pm4 + pm5 + pm6; } document.getElementById("Mod0EditRecord").onmouseover=calculate(); </script> There's my code, I don't know why it's not executing. I tried using the Inspect option in my browser and found this... being called on this line var pm1 = document.getElementById("cbParamVirtual3").value; The field is not null, so I inspected the field I inspected that field and the inspector tells me the Id of that field is actually as follows: So it seems a random set of characters is being added at the end of all my fields, making me unable to "getElementById" since I'll never know what the random set is going to be... How can I either find out that random set or stop it from being generated? Thanks!
  6. Hello, I tried to apply the examples from other post but not sure if applies, so I will try if somebody can help me to address the problem. have a table of where one of the field is a "number". I can insert a new line on the top of the table, but I want that the value of the "number" field of the new line is automatically filled with the MAX+1 value of all the others number in the result table. I already have the aggregate with MAX+1 and I would like to pass this value in the hidden "number" field. Thanks for the help Bye, Sergio
  7. Hi everyone, I've found this followig javascript code that allows me to move listbox items to one another listbox. The code works as he is on a submission form. But now I would like te reference my database listbox instead of the exemple. Can someone help me? Thanks The name of my "from" listbox is ID_SEARCH_FORM and the "to" listbox is cbParamVirtual1. CSS: <style type="text/css"> select { width: 200px; float: left; } .controls { width: 40px; float: left; margin: 10px; } .controls a { background-color: #222222; border-radius: 4px; border: 2px solid #000; color: #ffffff; padding: 2px; font-size: 14px; text-decoration: none; display: inline-block; text-align: center; margin: 5px; width: 20px; } </style> JAVASCRIPT: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script> <script> function moveAll(from, to) { $('#'+from+' option').remove().appendTo('#'+to); } function moveSelected(from, to) { $('#'+from+' option:selected').remove().appendTo('#'+to); } function selectAll() { $("select option").attr("selected","selected"); } </script> HTML: <form name="selection" method="post" onSubmit="return selectAll()"> <select multiple size="10" id="from"> <option value="html">Html</option> <option value="css">Css</option> <option value="google">Google</option> <option value="javascript">Javascript</option> <option value="jquery">Jquery</option> <option value="regex">Regex</option> <option value="php">Php</option> <option value="mysql">Mysql</option> <option value="xml">Xml</option> <option value="json">Json</option> </select> <div class="controls"> <a href="javascript:moveAll('from', 'to')">&gt;&gt;</a> <a href="javascript:moveSelected('from', 'to')">&gt;</a> <a href="javascript:moveSelected('to', 'from')">&lt;</a> <a href="javascript:moveAll('to', 'from')" href="#">&lt;&lt;</a> </div> <select multiple id="to" size="10" name="topics[]"></select> <form>
  8. Hello, In a result list of Action Items (todo) I want the user to just check a box and the items on the line of the checkbox changes its status to "In Approval". I used this code in an HTML block (repeated every line), but doesn't seem to work. <input id="doneCheck" type="checkbox" onclick="done();"> <script> function done() { if (document.getElementById('doneCheck').checked) { document.getElementById("InsertRecordStatus").value="In Approval"; } } </script> Any advise? Thanks Sergio
  9. I have the Javascript in our submission form to format the phone numbers to this format: (123) 456-7890, but sometime I need to add an extension to that. Is there a way to edit the Javascript so that I have the option to have it look like this: (123) 456-7890 x123. I don't want to have a separate column in the table to add an extension because they aren't always there and it will show up funny in the results tables. Any thoughts?
  10. I need to calculate the total value of the fields GAD1 - GAD7 which are all drop downs with text that have a corresponding numeric value. that total needs to be inserted into the hidden field GAD_Score when the user submits the page. All of the fields mentioned above are number datatypes in the corresponding table. when I test it out using either the preview or on my website I get nothing in the GAD_Score field in my table, what am I missing? Here is the code I put in the footer of my data page. <SCRIPT LANGUAGE="JavaScript"> function calculate() { var v_GAD1 = parseFloat(document.getElementById("InsertRecordGAD_Q1").value); var v_GAD2 = parseFloat(document.getElementById("InsertRecordGAD_Q2").value); var v_GAD3 = parseFloat(document.getElementById("InsertRecordGAD_Q3").value); var v_GAD4 = parseFloat(document.getElementById("InsertRecordGAD_Q4").value); var v_GAD5 = parseFloat(document.getElementById("InsertRecordGAD_Q5").value); var v_GAD6 = parseFloat(document.getElementById("InsertRecordGAD_Q6").value); var v_GAD7 = parseFloat(document.getElementById("InsertRecordGAD_Q7").value); var v_GADSCORE= v_GAD1 + v_GAD2 + v_GAD3 + v_GAD4 + v_GAD5 + v_GAD6 + v_GAD7; document.getElementById("InsertRecordGAD_Score").value = Math.round(v_GADSCORE); } document.getElementById("caspioform").onsubmit=calculate; </SCRIPT> Any help would be greatly appreciated
  11. I have a currency field in a table and I am using a Submission form to enter new records into that table. I want to keep users from entering a value higher than $75,000 in the currency field when using the Submission form. I also want to set a minimum value. I considered using a lookup field with fixed values, but quickly determined the min/max range is too wide ($5,000 - $75,000) because I would need to include values for $5,000.00, $5,000.01, $5,000.02 and so on, all the way up to $75,000. The answer then is using Javascript. Does anybody have the code that will match data entered into the currency field against a minimum and maximum value?
  12. I have a submission form where the user clicks a link and it's supposed to do a simple calculation based on a few fields. I can't seem to get it to work right though. The fields are: MRP (currency) Supplier_Discount (number) Cost (currency) It's a simple calculation I need to do. The user enters the MRP and Supplier Discount and clicks the link to calculate and fill in the Cost. The calculation is Cost=MRP-(MRP*Supplier_Discount) so if: MRP = 1000 Supplier_Discount = .3 Cost = 700 I tested the link calling the js and it works (used a message to test it) and also tested simply doing Cost= MRP and that worked also. It's when I try to call Supplier_Discount and do a calculation that it's not working. I'm not sure if it's because Supplier_Discount is a number field and not currency or if I'm just missing some syntax but any help would be greatly appreciated. I have this in an html block at the bottom of the submission form: <SCRIPT LANGUAGE="JavaScript"> $("#k_cyourcost").click(function cyourcost(){ var MRP = document.getElementById("InsertRecordMRP").value; var Supplier_Discount = document.getElementById("InsertRecordSupplier_Discount").value; var Cost = (MRP)-((MRP)*(Supplier_Discount)); document.getElementById("InsertRecordCost").value= Cost; }); </SCRIPT>
  13. Hi, While being fairly new to javascript. I was wondering if it is possible to do a calculation with a Virtual field which is set up as cascading text field to look up information from a different table. I cannot get it to work while when using a regular text field and the data is put in manually it works.
  14. Hi i'm a newbie to scripting of any sorts and i have a problem i'm trying to replace a text field on a submission form based on the contents of another field (dropdown), with the contents of either of two other text fields. In essence if the contents of one field "Name_Type" equal "Muscle Group" then I want the field "Workout_Name" to equal the contents of the Muscle_Group_id field, likewise if the contents of field "Name_Type" equal "Workout_Type" then I want the field "Workout_Name" to equal the contents of the Workout_Type_id field. If neither is the case then I want the contents of the field "Workout_Name" to stay as it is. If had an attempt at scripting this which I placed in the footer of the submission datapage but without success, can anyone help? <SCRIPT LANGUAGE="JavaScript"> function replace () var name_type = document.getElementById("InsertRecordName_Type").value; var muscleG = document.getElementById("InsertRecordMuscle_Group_id").value; var workType = document.getElementById("InsertRecordWorkout_Type_id").value; var work_name = document.getElementById("InsertRecordWorkout_Name").value; if (name_type = "Muscle Group") { var Work_nameSubmit = muscleG; } else if (name_type = "Workout Type") { var Work_nameSubmit = workType; } else { var Work_nameSubmit = work_name; } document.getElementById("caspioform").onsubmit=replace; </SCRIPT>
  15. The script below can be inserted into a footer. It preselects all rows with a value greater than 1, so that they can be Bulk Edited. It loops for a field in a tabular datapage with a class of cbResultSetTableCellNumberDate, and then it looks for the value of the text of those cells that match. On my datapage, I have just 1 column with numerical data, so I don't need a more specific selector than that... Then, it jumps up to the Row of the matching cell, then down to the first element in the Row (the cell that holds the checkbox), then down again to the checkbox itself, then uses a click event to check the box. To make use of Bulk Edit, a click event must be used, and not document.getElementById("checkbox").checked = true; because Bulk Edit is grayed out until there is a click (not a change) event. <script type="text/javascript"> var elems = document.querySelectorAll(".cbResultSetTableCellNumberDate"); for (var i=0, m=elems.length; i<m; i++) { if (elems.innerText >= 1) { elems.parentNode.firstChild.firstChild.click(); } } </script>
  16. I can't figure out a javascript to disable this checkbox, to the left of the Yes group. The script must check for Yes, because sometimes only the (blank) group exists, and sometimes only (blank) and Yes, and sometimes (blank) No and Yes. Can't use CSS as far as I can tell. The goal is to prevent the mass-selection of Yes records. I tried using some javascript browser addons to find an appropriate selector, but was my first time using and no luck. I also tried using .prev() in jQuery, but now I don't think the checkbox is a sibling. I tried modifying the code used to conditionally format rows, but those are inserted into HTML blocks for records, and so can't operate on Group rows. Thanks in advance!
  17. We have an App that ideally we would like a user to be able to use the Bulk Edit facility to amend a value within a field and have this applied to all applicable records. So far so good. But we also need that value added to another notes type field within each of the affected records. In other datapages we use some javascript to concatenate the "value" to the notes field - you press Update and it all works great. Ideally would love to be able to do this with a Bulk Edit facility. However we have tried it and it did not seem to work. Perhaps the JS just wont work in this setting. Anyone any ideas for how we might achieve same or similar effect? George
  18. Hi all, I'm quite new to Caspio and to digital stuff so please bare with me. I'm currently using the code below to format the 7th column of my table red, amber of green depending on the value in each cell. <SCRIPT LANGUAGE="JavaScript"> var elems = document.getElementsByTagName("td");for (var i=0, m=elems.length; i<m; i++) { if (elems[i].innerHTML=="Low") { elems[i].style.color="red";} if (elems[i].innerHTML=="Low") {elems[i].style.backgroundColor="lightpink"} if (elems[i].innerHTML=="Mid") { elems[i].style.color="orange";} if (elems[i].innerHTML=="Mid") {elems[i].style.backgroundColor="wheat"} if (elems[i].innerHTML=="High") { elems[i].style.color="green";} if (elems[i].innerHTML=="High") {elems[i].style.backgroundColor="LightGreen"}} </SCRIPT> However, whenever I sort the table results by clicking the column headings or try to move onto the next page of results (by using the arrow buttons at the bottom of the page) all of the formatting generated by the code above disappears. Currently this code is located in the footer. Does anyone know how to prevent this from happening?
  19. I am trying to filter datapages that are embedded within a page that I show within an iframe and I can not seem to get the parameters to pass into the I-Frame when the parent page is loaded. I have a "Project" report with custom link to details page. This link passes Project_ID fine to datapages actually embedded on the target page. What I want to do is embed other pages (hosted on same domain) via IFrame and have the results of datapages embedded on the page shown in iframe filtered by the Project_ID. I want to use I frames to reduce load time, data usage and also have the ability to refresh specific datapages when editing data. Again, the parent page that hosts the Iframe is receiving the parameter fine, i just can not get the DPs within the embedded page to see the passed parameter. Much help in advance!
  20. i have a field on a submission data page which if checked will display other other fields to be checked which have been hidden by a rule, but if I un-check the parent field the children fields disappear but remain checked. Can I use JS to clear the children cells if the parent is un-checked? many thanks
  21. Hi, I have an html page with 2 datapages in it. Both are in their own divs. I'm trying to get the second div called 'callback' to refresh every 6 seconds. I've got this javascript to do it function autoRefresh_div() { $("#callback").load("https://c1eru548.caspio.com/dp.asp?AppKey=f6344000919808bbf8fb4bb59cec&xip_Email=[@authfield:Email]&xip_Current_Password=[@authfield:Current_Password]"); } setInterval('autoRefresh_div()', 6000) The URL in the js is the deployment URL from Caspio for the datapage I want refreshing. Users login into the app and the first page they get is this html page. Both divs load fine at this stage. After 6 seconds the second div refreshes fine, but the system is putting up the User Name and Password fields again so they have to login again. As you can see I've tried to add these parameters to the URL so it autologs in. However, if I paste the URL it to the same brower window where the two Datapages are it works fine. So it works if I open it in a full pages after the initial login, but it won't work if it's refreshing a div in the same page. Any help much appriciate.
  22. Hi, I have an html page with 2 datapages in it. Both are in their own divs. I'm trying to get the second div, called 'callback', to refresh every 6 seconds. I don't want to refresh the first div. I've got this javascript to do it function autoRefresh_div() { $("#callback").load("https://c1eru548.caspio.com/dp.asp?AppKey=f6344000919808bbf8fb4bb59cec&Email=[@authfield:Email]&Current_Password=[@authfield:Current_Password]"); } setInterval('autoRefresh_div()', 6000); The URL in the function autoRefresh_div is the deployment URL from Caspio for the datapage I want refreshing. Users login into the app and the first page they get is this html page. After 6 seconds the second div refreshes fine, but the system is putting up the standard User Name and Password fields again in the second div, so the user has to login again. The first div isn't doing anything which is the desired action. As you can see I've tried to add these parameters to the URL so it autologs in. Unforutnately it isn't working. If anyone has any ideas that woud be great. Thanks
  23. I learned how to duplicate a record from a DataPage into a table using sub-query strings, hidden pages and auto-submit. The only thing I was not able to duplicate was the record picture. Any one knows how to do that? Sincerely, JaredL
  24. I am creating an application where I log daily events so I can view them in a DataPage report. I would like to be able to copy a record if I repeat an event, instead of re-entering the data in a web form. I was told I would have to create a hidden DataPage that auto submits the data, that will require some use of JavaScript. How do I create a hidden DataPage that auto submits data with JavaScript?
  25. I have a javascript code I got off of this forum that takes an inputted ten digit number and adds formatting (ie 1234567891 gets changed to (123) 456-7891). I have a field that will always be ######-###### and I'd like to modify the code to add the dash in the middle. What I'm trying to avoid is having someone needing to click on multiple boxes to fill out the entire field. I'm not great with javascript, so I was hoping someone on here would be able to help me with that. Here is the code: <SCRIPT LANGUAGE="JavaScript"> function f_a(v_id) { return document.getElementById(v_id); } f_a('InsertRecordPhone').maxLength = 14; f_a('InsertRecordPhone').onkeyup = function(v_e) { 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)); }; } </SCRIPT>
×
×
  • Create New...