Jump to content

Xiang

Caspio Guru
  • Content Count

    75
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by Xiang

  1. Hi hsilvermanmdjd, How are you? How's the weather in your city? I'm sorry that I answer instead of MayMusic, but - you can change the "InsertRecordFIELDNAME" to "EditRecordFIELDNAME", then the script will work on the Details page too.
  2. Hi Shelley, Welcome to our community! How are you? How's the weather in your city? "Timestamp" is set only when a record is added to a table, and the code cannot get the value of this parameter. If you have used alert to see the value of the field, it is "SYSDATE" until the record is created in the table. The "new Date();" method returns the current time, usually it's not worse than Timestamp. I hope, this code can help: <SCRIPT LANGUAGE="JavaScript"> function setDate() { var myDate = new Date(); myDate.setFullYear(myDate.getFullYear()+1); var myMonth = myDate.getMonth() + 1; if (myMonth<10) {myMonth = "0" + myMonth;} var myDay = myDate.getDate(); if (myDay<10) {myDay = "0" + myDay;} var myYear = myDate.getFullYear(); var result = myMonth + "/" + myDay + "/" + myYear; document.getElementById("InsertRecordsecond").value=result; } document.getElementById("caspioform").onsubmit=setDate; </SCRIPT> I'll be grateful, if you tell me if the code works. Have a nice day!
  3. Hi Ababcock, How are you? How's the weather in your city? I think, this script can help: <SCRIPT LANGUAGE="JavaScript"> function setDate() { var stringDate = document.getElementById("InsertRecordDATE_SUBMIT").value; var myDate = new Date(Date.parse(stringDate)); myDate.setFullYear(myDate.getFullYear()+1); var myMonth = myDate.getMonth() + 1; if (myMonth<10) {myMonth = "0" + myMonth;} var myDay = myDate.getDate(); if (myDay<10) {myDay = "0" + myDay;} var myYear = myDate.getFullYear(); var result = myMonth + "/" + myDay + "/" + myYear; document.getElementById("InsertRecordEXPIRATION_DATE").value=result; } document.getElementById("caspioform").onsubmit=setDate; </SCRIPT> Don't forget to change names of fields, DATE_SUBMIT and EXPIRATION_DATE to names of yours fields. I'll be grateful, if you tell me if the code works. Have a nice day!
  4. Hi DataCobalt, I've investigated how it works, and I've found the following formula: 100*Count(case when [@field:@current]=0 then 1 else NULL end)/Count You can use "[@field:@current]" instead of the current field. Have a nice day!
  5. Hi DataCobalt, How are you? I think, you can use this formula in your Aggregation field: Count(case when FIELDNAME=0 then 1 else NULL end) Or this formula to calculate the percentage: 100*Count(case when FIELDNAME=0 then 1 else NULL end)/Count I'll be grateful, if you tell me if the code works. Have a nice day!
  6. Hi Cameron, How are you? I think, you can add a Header and Footer element, select the Footer element, click the Source button or disable the HTML Editor, and enter the following code: <script> document.getElementById("InsertRecordFIELDNAME").setAttribute("onchange","loadFile(event)"); var loadFile = function(event) { var output = document.getElementById('output'); output.src = URL.createObjectURL(event.target.files[0]); }; </script> Enter the name of your field instead of "FIELDNAME". And add an HTML Block, click the Source button or disable the HTML Editor, and enter the following code: <img id="output"/> Then the image will be displayed in full size. If you want to display with the fixed size, add width and height, for example: <img id="output" width="200px" height="100px" /> But in this case, all images will be displayed with these parameters. Sometimes it is horrible I'll be grateful, if you tell me if the code works. Have a nice day! And thank you to Nkron
  7. Wow! Thank you for the solution! It's amazing! And you can add any comparison, if you want to calculate records by any condition. So simple, so cool! I can only add, that I hide all data with the following code in the Header: <style> .cbResultSetData { display:none; } </style>
  8. Hi Jon, How are you? I think, that tables may have different width and height depends on the width of the content, colspans and many others things, and divs are not. I think, your solution is very good. Thank you for sharing it!
  9. Hi Larson, How are you? Do you need a some kind of an Authentication, don't you? Only if a user enters "Agree" or checks a checkbox, she can see the next form. Is it correct? If yes, I think, I have a solution.
  10. Good morning menathansmith, I think, it's better to add a Header and Footer element, select the Footer element, click the Source button and enter the code. Does it work?
  11. Good morning Carl, How are you? I think, you can add the following script to an HTML block: <script> var myMessage = "Please go to the link to see the content of the page: "; var myLink = "http://caspio.com"; myMessage = myMessage + '<a href="' + myLink + '">' + myLink + '</a>'; if ((navigator.userAgent.indexOf("MSIE 7") != -1) | (navigator.userAgent.indexOf("MSIE 8") != -1)) { if ((navigator.userAgent.indexOf("Windows NT 5.1") != -1) | (navigator.userAgent.indexOf("Windows NT 5.2") != -1)) document.write(myMessage); } </script> Please, enter your message and your link. I'll be grateful, if you tell me if the code works. Have a nice day!
  12. Good morning DataCobalt, How are you? I like your idea, let me know if I can help you. I thought myself about a post, that contains links to posts with Java Scripts solutions, something like "Content"...
  13. Good morning Sidhartha, How are you? I think, you can use the following code to change the text of a label on a Submission Form: document.getElementById("InsertRecordFEILDNAME").parentNode.previousSibling.firstChild.innerHTML="NEW LABEL"; Please, enter the name of your field instead of FIELDNAME and your text instead of "new label". I'll be grateful, if you tell me if the code works. Have a nice day!
  14. Good morning, I think, the following script can do the same. The code for Header: <h1 id="loadingTitle" style="display: none">Loading...</h1> <div id="mainText" style=""> The code for Footer: </div> <script> document.getElementById('caspioform').onsubmit = function() { document.getElementById('loadingTitle').style.display = ''; document.getElementById('mainText').style.display = 'none'; } </script> I'm sorry, I don't understand for what the 'appkey_number' is used in the first script?
  15. Good morning Mente, How are you? I think, you can use the Id of the Update button (Mod0EditRecord) instead of "Submit": document.getElementById("Mod0EditRecord").style.display = "none"; And if you want to hide the button, it's better to place the code under the button - in the Footer of the DataPage. You can add the Header&Footer element, select the "Footer" element, click the "Source" button, and enter your code. Have a nice day!
  16. Good morning Allen, How are you doing? In Java Script, "{" means "Start" and "}" means "Finish". So, if you want to do several actions in a function, I think, it's better don't write "Finish" and then "Start" again between them, the function doesn't execute any code after the "Finish" sign. In setTimeout('document.forms["caspioform"].submit()',0); }, "0" means how long a DataPage waits before auto submits. It's better to use "1000", at least "100" milliseconds, then you allow a DataPage to load and then autosubmit it. And if you want to call another function before autosubmit, you can write the same code but for another function: setTimeout('calculate()',500); } Then the whole code will be like: <SCRIPT LANGUAGE="JavaScript"> function calculate() { var v_Current_Plan = parseFloat(document.getElementById("InsertRecordCurrent_Plan").value); var v_Current_Fee = parseFloat(document.getElementById("InsertRecordCurrent_Fee").value); var v_Rate= .08; var v_total = (((v_Current_Plan * v_Rate) + v_Current_Plan) - (((v_Current_Plan * v_Rate) + v_Current_Plan) * v_Current_Fee)); document.getElementById("InsertRecordCurrent_Plan").value = Math.round(v_total); var v_New_Plan = parseFloat(document.getElementById("InsertRecordNew_Plan").value); var v_New_Fee = parseFloat(document.getElementById("InsertRecordNew_Fee").value); var v_Rate= .08; var v_total = (((v_New_Plan * v_Rate) + v_New_Plan) - (((v_New_Plan * v_Rate) + v_New_Plan) * v_New_Fee)); document.getElementById("InsertRecordNew_Plan").value = Math.round(v_total); } if(document.getElementById("caspioform")) { document.getElementById("caspioform").style.display = 'none'; setTimeout('calculate()',500); setTimeout('document.forms["caspioform"].submit()',1000); } </script> I'm learning the JavaScript now, so, I'll be grateful, if you tell me if the code works. Have a nice day!
  17. Good morning Spazz, How are you doing? I think, you can add an HTML Block on your Report and enter the following code: <script>var birth_day = '[@field:birthday]'; var date_birth = new Date(birth_day); var date_today = new Date(); var timeDiff = Math.abs(date_today.getTime() - date_birth.getTime()); var diffYears = Math.ceil(timeDiff / (1000 * 3600 * 24 * 365.25)); document.write(diffYears); </script> Insert the name of your field instead of "birthday". I'm learning the JavaScript now, so, I'll be grateful, if you tell me if the code works. Have a nice day!
  18. Hi Liz, I have tried to click Submit and I see different meesages whten different options are selected. Could you please provide expected result, if Pass Thru is selected and if it is not selected? When and what should be displayed? I am afraid, I misunderstand you and propose incorrect Scripts.
  19. Hi Liz, If you want to allow a user submits a record, you can delete the following string: return false; Then the message is displayed, but when a user clicks "Ok", the record is submitted. If you want do not display the message, you can delete the following string as well: alert('Please select Pass Thru to continue');
  20. Xiang

    Authorized menu's

    Good morning Romano, How are you doing? I think, you can combine two solutions, Create User-Specific Redirect After Login and Create a Floating Navigation Menu. You can create an HTML Page, enter the following code and then embed the DataPage on your web page: <style> #menu { margin:0; list-style: none; width: 140px; text-align: center; } #menu li { font: 90% "Arial", Arial, Helvetica, sans-serif; margin: 0; padding: 0; } #menu a { background: #222; /*Standard Color*/ border-bottom: 1px solid #000000; color: #ccc; display: block; margin: 0; padding: 20px 12px; text-decoration: none; } #menu a:hover { background: #004400; /*Hovered Color*/ color: #fff; text-shadow:#ffffff 0px 0px 5px; /*Text Glow*/ padding-bottom: 20px; } </style> <div style="position:fixed; top:0; right:0;"> <ul> <li id="Link1"><a href="http://google.com">Google</a></li> <li id="Link2"><a href="https://www.wikipedia.org/">Wiki</a></li> <li id="Link3"><a href="http://www.w3schools.com/">W3schools</a></li> <li id="Link4"><a href="http://www.w3schools.com/js/default.asp">W3schools JS</a></li> <li><a href="https://YourSite/folderlogout" title="Logout">Logout</a></li> </ul> </div> <script> var link1 = document.getElementById("Link1"); var link2 = document.getElementById("Link2"); var link3 = document.getElementById("Link3"); var link4 = document.getElementById("Link4"); if("[@authfield:Admin]" == "Yes"){ link1.style.display = "none"; link2.style.display = "none"; } else if ("[@authfield:Manager]" == "Yes"){ link3.style.display = "none"; link4.style.display = "none"; } else{ link1.style.display = "none"; link2.style.display = "none"; link3.style.display = "none"; link4.style.display = "none"; } </script> An Admin user sees Link3 and Link4, a manager user sees Link1 and Link2. User without roles sees only the Logout link. I'm learning the JavaScript now, so, I'll be grateful, if you tell me if the code works. Have a nice day!
  21. Hi Liz, You can re-write the followin part of youre code: /*Check if v_invtotal = v_trans*/ if ( v_invtotal == v_trans) { /* Insert a value of the variable v_invtotal into the DataPage field Invoice_Total */ document.getElementById("InsertRecordTotalTransaction").value = v_invtotal; } else { alert('Invoice Total does not equal Transaction Totals. Please re-enter values'); } } /* On submitting the webform, the function calculate is executed */ document.getElementById("caspioform").onsubmit=calculate; </SCRIPT> With the following code: /* Check if the "Pass thru" radio button is selected */ if (document.getElementById("InsertRecordOrderType0").checked) { /*Check if v_invtotal = v_trans*/ if ( v_invtotal == v_trans) { /* Insert a value of the variable v_invtotal into the DataPage field Invoice_Total */ document.getElementById("InsertRecordTotalTransaction").value = v_invtotal; } else { alert('Invoice Total does not equal Transaction Totals. Please re-enter values'); } } else { alert('Please select Pass Thru to continue'); return false; } } /* On submitting the webform, the function calculate is executed */ document.getElementById("caspioform").onsubmit=calculate; </SCRIPT> I'll be grateful, if you tell me if this code works as you want.
  22. Hi Liz, Oh, it is my fail. I think, now I understand the task better. Could you tell me the order of option for the RadioButton and the name of the field? Or could you provide the URL of your page?
  23. Good afternoon Liz, How are you doing? I think, you can enter the following code before the "/*Check if v_invtotal = v_trans*/" line: /* Get the Value of RadioButton field */ var value_rb = document.getElementById("InsertRecordRadioButton2").checked; /* Check if the correct radio button is checked */ if (!value_rb) { alert('ERROR MESSAGE'); return false; } The name "InsertRecordRadioButton2" contains three parts: InsertRecord - prefix, RadioButton - the name of your field; 2 - is the radio button option order, which starts at 0 and increments based on the order of each radio option. For example if your radio button has three options: Incorrect, Wrong, Pass Thru. - Incorrect is InsertRecordFIELDNAME0 - Wrong is InsertRecordFIELDNAME1 - Pass Thru is InsertRecordFIELDNAME2 Enter your error message instead of "ERROR MESSAGE". I'm learning the JavaScript now, so, I'll be grateful, if you tell me if the code works. Have a nice day!
  24. Good morning, Desi! How are you doing? I think, you can use a JavaScript code. This code should work: <SCRIPT LANGUAGE="JavaScript"> function costcalculate() { var cost = parseFloat(document.getElementById("InsertRecordCost").value); var markup = parseFloat(document.getElementById("InsertRecordMarkup").value); document.getElementById("InsertRecordPrice").value = cost*markup+cost; } function markupcalculate() { var cost = parseFloat(document.getElementById("InsertRecordCost").value); var markup = parseFloat(document.getElementById("InsertRecordMarkup").value); if (cost==0) { document.getElementById("InsertRecordMarkup").value = 0.5; alert("You cannot markup a 0 value"); } else document.getElementById("InsertRecordPrice").value = cost*markup+cost; } function pricecalculate() { var cost = parseFloat(document.getElementById("InsertRecordCost").value); var price = parseFloat(document.getElementById("InsertRecordPrice").value); document.getElementById("InsertRecordMarkup").value=price/cost-1; } document.getElementById("InsertRecordCost").onchange = costcalculate; document.getElementById("InsertRecordMarkup").onchange = markupcalculate; document.getElementById("InsertRecordPrice").onchange = pricecalculate; </SCRIPT> I'm learning the JavaScript now, so, I'll be grateful, if you tell me if the code works. Have a nice day!
  25. Good evening, Michael! How are you doing? I'm learning the JavaScript now, so, I think, capital letters are a problem. Names of your fields don't contain them, but the code does. This code should work: <SCRIPT LANGUAGE="JavaScript"> function concatenate() { var position1 = document.getElementById("InsertRecordPosition1").value; var position2 = document.getElementById("InsertRecordPosition2").value; var allpositions = position1 + position2; document.getElementById("InsertRecordAllPositions").value = allpositions; } document.getElementById("caspioform").onsubmit=concatenate; </SCRIPT> I'll be grateful, if you tell me if the code works. Have a nice day!
×
×
  • Create New...