htamraz Posted May 18, 2016 Report Share Posted May 18, 2016 Hello, I have a multi-select listbox on a datapage called "TeachingArtists" where a user can select one or more artists and assign them to an educational program that is taught in schools. On a separate data page, I have the user selecting the program name and have a cascading listbox that filters on program name so user sees only the artists linked to the program name. The problem I am running into is that the some of the entries in the listbox contain multiple values of artists names separated by commas where ideally I want each artist name listed separately. Is there a way that I can parse the comma delimited artist name values and present them as single entries in the listbox? I am attaching a screen shot for reference. Thank you for your help. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted May 23, 2016 Report Share Posted May 23, 2016 If you have an update page for user to see selected values selected separately you can use the code at http://forums.caspio.com/index.php/topic/4315-js-multiselect-listbox-in-update-datapage/ It will separate the values and highlight them when the page loads Quote Link to comment Share on other sites More sharing options...
htamraz Posted May 24, 2016 Author Report Share Posted May 24, 2016 Thank you, but I already have a JavaScript that stores multiple selections as comma delimited entries. My problem is that if I need to reference the comma delimited values at a later time in a another listbox, they are presented as one record delimited by comma. I would have liked to have had a way to parse (i.e. break) the list so each entry separated by a comma is presented separately as opposed to being part of one string. For example, the entry: Red,Green,Purple Would be presented as: Red Green Purple Quote Link to comment Share on other sites More sharing options...
MayMusic Posted May 24, 2016 Report Share Posted May 24, 2016 The above code is to enable multi select as well as separate the values where there is a comma and then select them in a listbox, instead of showing them all together separated by comma... But if you want to have them stored in different rows in a table to be used as a lookup table later on, there needs to be some server side programming ... Quote Link to comment Share on other sites More sharing options...
htamraz Posted May 24, 2016 Author Report Share Posted May 24, 2016 Thanks again for the helpful feedback. Let me give it a try. As you said, I only need to multi select as well as separate the values where there is a comma and then select them in a listbox, instead of showing them all together separated by comma. I don't need to store them in different rows. Quote Link to comment Share on other sites More sharing options...
MayMusic Posted May 24, 2016 Report Share Posted May 24, 2016 Please note this will help when you have an update or details page based on the same table you have stored Red,Green,Purple So [@field:state] in this line var v_state = "[@field:state]" ; would be the field you have comma separated values in. Quote Link to comment Share on other sites More sharing options...
RkaydianFlower Posted October 21, 2016 Report Share Posted October 21, 2016 I have a similar issue, but on a Submission DataPage, and I don't need any preselection. Using javascript I was able to create a multi-select listbox that stores the user’s selections as comma-separated values in a single line: writer, director, actor, producer Now I would like to create a Search List DataPage that allows users to search this data using a listbox like this: writer director actor producer Currently, the comma-separated values from each user’s submissions show on a single line. How can I get these values broken up onto separate lines of the listbox on a List DataPage? TWIRED 1 Quote Link to comment Share on other sites More sharing options...
TWIRED Posted November 26, 2016 Report Share Posted November 26, 2016 explained below.. Quote Link to comment Share on other sites More sharing options...
TWIRED Posted January 14, 2017 Report Share Posted January 14, 2017 On 5/24/2016 at 11:48 AM, MayMusic said: The above code is to enable multi select as well as separate the values where there is a comma and then select them in a listbox, instead of showing them all together separated by comma... But if you want to have them stored in different rows in a table to be used as a lookup table later on, there needs to be some server side programming ... Multi Select Listbox (Submission Form) - On Errror Javascript Code Required. Pseudo Code - REQUIREMENT FOR Multi-Select Listbox in a Submission Form ON FIRST TIME LOAD - Read the values from the table field into a variable If field is blank - then dont do anything Just populate the listbox from default element custom values ON SUBMIT (SAME PAGE) -MULTIPLE VALUES SELECTED Store the “selected value”s from listbox in an array in a hidden element or a temp persistent variable or maybe a hidden virtual field ON ERROR - REFRESH If theres an error:- like other required fields are not filled in on form (The values are not yet committed to the database) Then Load the hidden element “selected values” array In the Listbox - Match the variables array values with the drop down list element custom values and Highlight and show them as selected . IF NO ERROR Then submit values in delimited string to table. Thanks! Quote Link to comment Share on other sites More sharing options...
Wikiwi Posted July 12, 2022 Report Share Posted July 12, 2022 To parse your comma separated data, you might want to look into this article: 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.