ShidarthaRosa Posted August 26, 2015 Report Share Posted August 26, 2015 Hello!I am using a javascript code to change the values of some text fields everytime the user choose a value on a dropdown list at a submission form. This is the code:<SCRIPT LANGUAGE="JavaScript">function atualizacampos(){var text1 = document.getElementById('InsertRecordEntidades_Canais_Info_1');var text2 = document.getElementById('InsertRecordEntidades_Canais_Info_2');var text3 = document.getElementById('InsertRecordEntidades_Canais_Info_3');var text4 = document.getElementById('InsertRecordEntidades_Canais_Info_4');var dropC = document.getElementById('InsertRecordEntidades_Canais_ID_Canal_Doacao'); var Cselecionado = dropC.options[dropC.selectedIndex].text;switch(Cselecionado) {case 'Depósito Bancário':text1.value='Agência'break;case 'Nota Fiscal':text1.value='Número da Nota';break;case 'Paypal':text1.value='Código Paypal';break;default:}}document.getElementById('InsertRecordEntidades_Canais_ID_Canal_Doacao').onchange=atualizacampos;</SCRIPT>This is already working, but right now i am trying to change also the labels of those text fields.I already tried some sibblings options, but it did not work. Can you guys please tell me the correct code to achieve that? So everytime a user change the dropdown value, the text1.value will be changed and also the label associated with this field will be changed for a new value. Can someone please help? My best regards,Shidartha Quote Link to comment Share on other sites More sharing options...
iren Posted August 27, 2015 Report Share Posted August 27, 2015 Hello Shidartha, You can use the lookup table for the 'Dropdown' form element. The script does not change values in the lookup table. The article: 'http://howto.caspio.com/tables-and-views/lookup-tables/' explains in further details. Hope it helps. Quote Link to comment Share on other sites More sharing options...
ShidarthaRosa Posted August 29, 2015 Author Report Share Posted August 29, 2015 I just need to know how to change the label value (label caption) of a field on a submission form via javascript. Anyone knows this? Regards, Shidartha nickword 1 Quote Link to comment Share on other sites More sharing options...
Xiang Posted September 2, 2015 Report Share Posted September 2, 2015 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! nickword 1 Quote Link to comment Share on other sites More sharing options...
Kurumi Posted July 22, 2019 Report Share Posted July 22, 2019 Hi @ShidarthaRosa, Just an update: Based on your workflow, you can use Virtual field as a label and set it as Calculated Value. Calculated Value form element generates dynamic calculations that automatically update as users interact with your form. Similar to Formula Fields and Calculated Fields, you can construct the calculation using functions, logic, constants, values from other fields and SQL expressions. For more information about Calculated Values, check this article: https://howto.caspio.com/datapages/datapage-components/calculated-values/ What is Virtual Field?https://howto.caspio.com/datapages/datapage-components/virtual-fields/ Hope it helps! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.