wvantongeren Posted June 17, 2016 Report Share Posted June 17, 2016 I'm curious if en how an enduser can change labelnames, is that possible? Quote Link to comment Share on other sites More sharing options...
Mathilda Posted June 17, 2016 Report Share Posted June 17, 2016 Hi Willem, how are you? Yes, it's possible to change field names depending on user's input. For example, when user enter his name, we can add his name to the label. label value 1st field: First Name John 2nd field: John, enter your last name ______ 3rd field: John, enter your age ______ Try using the following script for this purpose: <script> var input = document.getElementById('InsertRecordFirstName'); var labels = document.querySelectorAll('label'); function changeLabels (){ for (var i = 0; i < labels.length; i++) { labels[i].textContent = input.value + labels[i].textContent ; } } input.addEventListener('change', changeLabels); </script> Please replace "FirstName" with your field name in the script. Hope it helps! Quote Link to comment Share on other sites More sharing options...
wvantongeren Posted June 17, 2016 Author Report Share Posted June 17, 2016 Hey, Mathilda. I'm fine thak you for asking. I hope you are doing good as well. I'm gona trie your script, I hope it works. Thank you. Mathilda 1 Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 17, 2016 Report Share Posted June 17, 2016 That worked for me it changes all the labels even the first name. How can we change a specific label not all? Quote Link to comment Share on other sites More sharing options...
Mathilda Posted June 23, 2016 Report Share Posted June 23, 2016 Hi MayMusic, I've changed the script a little bit. Try using the following script: <SCRIPT LANGUAGE="JavaScript"> var input = document.getElementById('InsertRecordFirst_field'); var labels = document.querySelector('label[for="InsertRecordSecond_field"]'); function changeLabels (){ labels.textContent = input.value +" " +labels.textContent ; } input.addEventListener('change', changeLabels); </SCRIPT> Please replace First_field and Second_field with your field names. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted June 23, 2016 Report Share Posted June 23, 2016 Thanks, I tried the code. When I add a text and then go back to change it, it keeps adding previous entries to the label and not cleaning up the deleted values. Quote Link to comment Share on other sites More sharing options...
wvantongeren Posted July 23, 2016 Author Report Share Posted July 23, 2016 Thank MayMusic and Mathilda! It works verry fine also with userpermissions. Great tool. 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.