Tip

A Notes UI for ordering a list

You've seen application where there is a list of items and a UP and a DOWN button which you can click to move a selected item up and down in the list. This tip show you how to do it in Notes.
If you want to do the same in a browser, you can use JavaScript.
This tip uses Notes formula.

All fields in this tip are editable.

Create a form, say test.
Create a text field called "values", and allow multiple values.
You can hide this field.
Create a Listbox (could be any other keywords type fields) field called leftBox.
Allow multiple values for this field. Change the height to 2 to make it looks like a box.
Use formula for choices. For this test form, I hard coded a couple of choices.
Create a Listbox field, rightBox.
Don't allow multiple values! (If you allow multiple values, the formula to move items up and down will be dramatically complicated).
Use formula for choice for rightBox. The formula is "values".
Check Refresh choices on document refresh. This is important.
Create three buttons.
The first button adds selected items from the leftBox to the rightBox.
The second button moves a selected item in the rightBox up.
The third button moves a selected item in the rightBox down.

Formula for the first button:

 @SetField("Values"; @Unique(values : leftBox)); @Command([ViewRefreshFields])

Formula for the second button:

 sep := "#*#"; selected := rightBox; @If(selected = ""; @Return(""); ""); oldvalues := " " + sep + @Implode(Values; sep) + sep + " "; l1 := @Left(oldvalues; sep + selected + sep); @If(l1 = " "; @Return(""); ""); l2 := @Right(oldvalues; sep + selected + sep); l3 := @LeftBack(l1; sep); l4 := @RightBack(l1; sep); l5 := l3 + sep + selected + sep + l4 + sep + l2; @SetField("Values"; @Trim(@Explode(l5; sep))); @Command([ViewRefreshFields])

Formula for the third button:

 sep := "#*#"; selected := rightBox; @If(selected = ""; @Return(""); ""); oldvalues := " " + sep + @Implode(Values; sep) + sep + " "; l1 := @Left(oldvalues; sep + selected + sep); l2 := @Right(oldvalues; sep + selected + sep); @If(l2 = " "; @Return(""); ""); l3 := @Left(l2; sep); l4 := @Right(l2; sep); l5 := l1 + sep + l3 + sep + selected + sep + l4; @SetField("Values"; @Trim(@Explode(l5; sep))); @Command([ViewRefreshFields])

This was first published in February 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.