GetOverHere Posted November 23, 2023 Report Share Posted November 23, 2023 Hey there! I hope someone can help as I am working on comma delimited values for my app and I already followed the solution provided in this post: In that solution, the values selected in the list box are Actual Values and saved into the same field. What I'm attempting to do is obtain those Listbox's Display Values and put them into my 'State' Text(255) Field. Here is my DataPage's listbox setup: Is this possible? Thanks! Quote Link to comment Share on other sites More sharing options...
Kurumi Posted November 23, 2023 Report Share Posted November 23, 2023 Hi @GetOverHere - this is possible. I found this article: https://stackoverflow.com/questions/28069061/get-the-multiple-selection-as-comma-separated-from-select-box-into-a-text-input that can help you. You can still use the same code from the forum post and add the other one for selecting the display data. Here's the code from your sample use case: <script> document.addEventListener('change', assignMultiple); function assignMultiple() { let fieldName = "InsertRecordPriority"; let x=document.getElementsByName(fieldName); x[0].multiple=true; var selObj = document.getElementById('InsertRecordPriority'); var txtTextObj = document.getElementById('InsertRecordState'); var selected = []; for(var i=0, l=selObj.options.length; i < l; i++){ if(selObj.options[i].selected){ selected.push(selObj.options[i].textContent); } } txtTextObj.value = selected.join(', '); } </script> This is applicable even if the 'State' field is set to the 'Hidden' form element. Code: <script> document.addEventListener('change', assignMultiple); function assignMultiple() { let fieldName = "InsertRecordLISTBOX_FIELDNAME"; let x=document.getElementsByName(fieldName); x[0].multiple=true; var selObj = document.getElementById('InsertRecordLISTBOX_FIELDNAME'); var txtTextObj = document.getElementById('InsertRecordTEXTFIELD_FIELDNAME'); var selected = []; for(var i=0, l=selObj.options.length; i < l; i++){ if(selObj.options[i].selected){ selected.push(selObj.options[i].textContent); } } txtTextObj.value = selected.join(', '); } </script> Sample Result: Hope it helps! GetOverHere 1 Quote Link to comment Share on other sites More sharing options...
GetOverHere Posted November 23, 2023 Author Report Share Posted November 23, 2023 Hello @Meekeee, this is exactly what I needed. Thank you so much for your help! Kurumi 1 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.