Jump to content

kytan5

Members
  • Content Count

    11
  • Joined

  • Last visited

  1. I checked F12 and it tells me TypeError: totalField is undefined This error comes from a javascript which is in a HTML block which I copied from another thread in this forum. (see script below) So, the live webpage does not recognise var totalField = document.getElementsByClassName('cbFormData')[0];?? <script type="text/javascript"> // Caspio form elements var UnitCostField = document.getElementById('InsertRecordLocalUnitCost'); var qtyField = document.getElementById('InsertRecordUnit'); var totalField = document.getElementsByClassName('cbFormData')[0]; var caspioForm = document.getElementById('caspioform'); // Event handler var calculateTotal = function (event) { // TODO: Do something on value change --> totalField.innerHTML = UnitCostField.value * qtyField.value; } // Run total calculation on input to any of these two fields UnitCostField.addEventListener('input', calculateTotal); qtyField.addEventListener('input', calculateTotal); </script>
  2. Hi I notice whenever I use javascript within caspio datapage and do a preview, it seems to work. However when I save my datapage and have it deployed to my web environment, the script does not work at all. Anyone know why and how I can fix this? Thanks in advance.
  3. I tried to use ID (only based on 1 set of formula) var totalField = document.getElementById("cbParamVirtual1"); however it does not seem to work. The Virtual Param is I have is not cascading. It is a display only field per the javascript I copied from.
  4. Hi Hope someone can help me out here with my javascript problem. I have a submission form (which is multi-step form, 2nd page of a form which is now a update form) which is collecting information like project type, project name, description. It is cascading from project type -> project name -> description Because I can't do a cascading text area for "description". I have created a virtual text field for this value hoping to copy this into the "description" text area. I am having no luck with javscript which I have modify from what i found on this forum. Can someone please help me? This is what I have came up with. <script type="text/javascript"> // Caspio form elements var description = document.getElementById('EditRecordDescription'); var temp_description = getElementsByName("cbParamVirtual1")[0].value; var caspioForm = document.getElementById('caspioform'); // Event handler var Copy = function () { // TODO: assign value to description field description.innerHTML = temp_description; } document.getElementById("caspioform").onload= Copy; </script>
  5. Hi I am stuck with javascript doing multiple calculations in same datapage. 1st javascript is calculation of unit cost, no of units and total (in local currency) 2nd javascript is convert local unit cost to USD based on cascading dropdown field 3rd javascript is using unit cost (in USD), no of units to derive total cost (in USD) the 1st javascript seems to be working. But when I add on 2nd javascript, only one value shows and in the wrong field. There is also no error appearing in the web console. Eg javascript 1 calculation = virtual field 1 = virtual field 1 value javascript 2 calculation = virtual field 2 = virtual field 2 value Instead what i see is this javascript 1 = virtual field 1 = virtual field 2 value javascript 2 = virtual field 2 = blank I followed basically this script and did my own modification http://forums.caspio.com/index.php?/topic/6053-perform-calculations-in-submission-form/ I think the problem is I did not define 2 variable that points to virtual field 1 and virtual field 2 respectively. var totalField = document.getElementsByClassName('cbFormData')[0]; I need 2 of it, and I do not how to define for the 2nd virtual field. Also, how do I pass the the virtual field to a table field? I used the Pass field value as parameter, it does not seem to write into the table. Can anyone please help? <script type="text/javascript"> // Caspio form elements to calculate local total cost var unitcostField = document.getElementById('InsertRecordLocalUnitCost'); var unitsField = document.getElementById('InsertRecordUnit'); // var totalField = document.getElementById("cbParamVirtual1"); ** I tried using this to point to virtual field but it did not work ** var totalField = document.getElementsByClassName('cbFormData')[0]; // Caspio form elements to convert local to USD cost var exchangerateField = document.getElementsByName("InsertRecordExchangeRate")[0]; //var convertField = document.getElementById("cbParamVirtual2"); ** I tried using this to point to virtual field but it did not work ** var convertField = document.getElementsByClassName('cbFormData')[0]; var caspioForm = document.getElementById('caspioform'); // Event handler var calculateTotal = function (event) { // TODO: Do something on value change --> totalField.innerHTML = unitcostField.value * unitsField.value; } var calculateExchangeRate = function (event) { // TODO: Do something on value change --> convertField.innerHTML = (1/exchangerateField.value) * unitcostField.value; } // Run total calculation on input to any of these two fields unitcostField.addEventListener('input', calculateTotal); unitsField.addEventListener('input', calculateTotal); unitsField.addEventListener('input', calculateExchangeRate); unitcostField.addEventListener('input', calculateExchangeRate); </script> Thanks in Advance
  6. I tried but what happen is now the bottom fields get line up in 1 row. Eg What I see on caspio form Brand Type: <text field> Type 1: <text field> Type 2: <text field>
  7. I use the below code in my caspio datapage under emails & destination as suggested by in the forum. It was working like a charm but suddenly now it does not work anymore. anyone can help with new code or why it is not working? <script> window.close(); window.onunload = function(){ window.opener.location.reload();} </script>
  8. Hi I used total & aggregation default function to calculation average score for table that has 12 months. The answer calculated has 6 decimal place but I want to have it round up. How do I fix this? There is nothing on the datapage round it up. Example (the actual calculation will give 2 decimal place in the below scenario. just for the purpose of illustrate, i have put in a dummy average value) Name Jan Feb Mar Name1 4.22 4.23 6.3 Name2 4.12 4.11 6.44 Mth Avg 4.31123 4.1732 12.74234 how can i round up to 2 decimal point 4.31123 to 4.31?
  9. I tried the padding, doesn't seem to do much. effect happens on cell width but it is hard to give 1 generic width to fill all scenarios.
  10. I have submission form and when i put label position = left. the field/form element (could be a textfield, dropdown etc) will appear to the far right. Example: Expected result I am looking for Brand Type: <text field> What I see on caspio form Brand Type: <text field> How do I reduce the spacing between label and form element? I don't know where in the style is controlling the spacing. I need the table or container to be 100% as my page is suppose to be responsive page. Can anyone help?
×
×
  • Create New...