Jump to content

Remove integers and commas from string in one field based on user selection in text255 field set to listbox with js multiselect


Recommended Posts

In a previous post in this forum I was hoping to use List-Type-String fields so the user can select multiple choices, but I can't use display/value (just one value). So instead I'll use a traditional Text255 field (TextField1) set to List field element on a datapage, with javascript so the user can multi-select records. This is saved as a comma delimited string where each record the user saves is an integer value (they see a text display value but the list box saves the integer as the record). 

This is the js to multi-select:

<SCRIPT LANGUAGE="JavaScript">
/* "fieldName" is the variable name for the listbox type form element field. */
   var fieldName = "EditRecordColumn_Hide";

   var x=document.getElementsByName(fieldName);
   x[0].multiple=true;

</SCRIPT>

Then I have a string with a set of numbers going from 20 to 1, in z/a sequential order, comma delimited. This string could be in table field or a virtual field (or just in a javascript line)--not sure the best approach. 

So this string would be 20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1

What I need to do is, in another text field (TextField2), remove the integer values (and their following comma) from the 20-1 string, so all that's left are integers the user has NOT selected in the list box. 

For example, if the user selects 5 records in the TextField1 listbox with a saved string  value 18,12,9,6,2 I would need the result in TextField2 to be 19,17,16,15,14,13,11,10,8,7,5,4,3,1

This can happen either as TextField1 changes with each selection the user makes, or after they mouse out, or before Update (this is on a Single Record Update datapage). This way I'll have just a string of integers (comma delimited) that the user did NOT select, in TextField2. 

Any help on this would be really appreciated. I'm using the final TextField2 string value to be passed as a parameter to another datapage (tabular) where js in the Search Footer uses the integers to remove columns in the results. The selections the user makes in TextField1 are header labels (and placement numbers) for columns in the tabular report. This enables the user to select which columns they want to see, making it a user-customizable report. 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...