Tip

Dynamic name/value pairs for HTML select fields

Generate name/value pairs in Domino with a small amount of code. Concatenate Evaluate statements in a WebQueryOpen agent and have a short formula in the field that will contain the select options. The value (not the label) is passed when the form is submitted.

The HTML for the field that is generated by Domino will look like:

 <OPTION VALUE="1">Briefing Material <OPTION VALUE="2">Memorandum

instead of the list being generated without values and the whole thing being selected by default, which will happen if you just insert a list into the field:

 <OPTION SELECTED>Briefing Material <OPTION SELECTED>Memorandum


WebQueryOpen Agent:

 Dim session As New notessession Dim db As notesdatabase Dim doc As notesdocument Dim tempDoc As NotesDocument Dim nameValuePair() As String Dim x As Integer Set db = session.CurrentDatabase Set doc=session.DocumentContext Set tempDoc = session.CurrentDatabase.CreateDocument ' The type of @DbLookup/Column is irrelevant tempDoc.ValueList = Evaluate ( {@DbColumn("ODBC" : "NoCache" ; "dbname" ; "userid" ; "password" ; "DocType" ; "Doc_Value" : "Discard" ; "Distinct" : "Ascending")}, tempDoc) tempDoc.LabelList = Evaluate ( {@DbColumn("ODBC" : "NoCache" ; "dbname" ; "userid" ; "password" ; "DocType" ; "Doc_Label" : "Discard" ; "Distinct" : "Ascending")}, tempDoc) x = -1 Forall i In tempDoc.ValueList x = x+ 1 Redim Preserve nameValuePair(x) ' Concatenate the input value and input label with pipe character | nameValuePair(x) = tempDoc.LabelList(x) & "|" & tempDoc.ValueList(x) End Forall Call tempDoc.RemoveItem ("ValueList") ' no need to keep the temporary field Call tempDoc.RemoveItem ("LabelList") ' no need to keep the temporary field doc.selectList = nameValuePair() 'insert the concatenated list into the field on the HTML form End Sub

The field on the form (selectList) is an editable dialog list. It uses a formula for choices:

 " " + selectList

This was first published in August 2001

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.