Tip

Generate combobox >64k on Web

To populate a field on a Web form, you call an agent which displays a combobox in a popup-window where you can select a view-entry from a view of unlimited size.
The agent is reusable because you pass him variables for the view to search and the field to populate.
In the given example I use the following elements:
View 'Aufnr'
Field 'Aufnr_'
Agent 'GenerateDialog'


On the form use a button with Javascript: 
var pathname = window.location.pathname);
url=pathname.substring(0,(pathname.lastIndexOf(".nsf")+5))+"GenerateDialog?OpenAgent&View=Aufnr&Field=Aufnr_";
window.open(url,"GenerateDialog","width=480,height=40,left=200,top=300");

Then create a LotusScript-Agent (manually from agent list, Run Once):
Sub Initialize
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim vc As NotesViewEntryCollection
	Dim entry As NotesViewEntry
	Dim doc As NotesDocument
	Dim strVIEW,strFIELD As String
	Dim querystring As String
	Dim Params List As String
	Dim i As Integer
	
	Set db = session.CurrentDatabase
	Set doc = session.DocumentContext
	
' pull the query_string from the DocumentContext which represents an instance of this agent
	querystring=doc.query_string(0)
	i = Instr(querystring, "&" )
	Do While i>0
		querystring = Mid(querystring, i+1)
		i=Instr(querystring,"=")
		If i>0 Then 
' Get the Variable Name
			varname = Left(querystring,i-1)
		Else 
			Exit Do 
		End If
		querystring=Mid(querystring, i+1)
		i=Instr(querystring,"&") 
		If i>0 Then 
' Get the Value
			value = Left(querystring, i-1) 
		Else 
			value=querystring
		End If
		
' Save the Parameter in the list
		Params(varname)=value
	Loop
	
	strVIEW=Params("View")
	strFIELD=Params("Field")
	Set view = db.GetView(strVIEW)
	Set vc = view.AllEntries
	
' Generate the HTML-Doc
	Print "Content-Type: text/html" 
	Print "" 
	Print "<HTML><HEAD>"
	Print "<SCRIPT LANGUAGE=""JavaScript"">"
	Print "<!--"
	Print "function CheckSelection() {"
	Print "var frm=window.document._GenerateDialog;"
	Print "for(i=0;i<frm.Sel.length;++i)"
	Print "if(frm.Sel.options[i].selected == true)"
	Print "frmMain."+strFIELD+".value=frm.Sel.options[i].text"
	Print"self.close();"
	Print "} // -->"
	Print "</SCRIPT>"
	Print "<TITLE>Bitte wahlen Sie einen Eintrag</TITLE></HEAD>"
	Print "<BODY BGCOLOR=""DAFBFE"" onLoad=""frmMain = window.opener.document.forms[0]"">"
	Print "<FORM METHOD=post NAME=""_GenerateDialog"">"
	Print "<BR>"
	Print "<CENTER>"
' Fill in the Options 	
	Print "<SELECT NAME=""Sel"" onChange=""CheckSelection()"">"
	Print "<OPTION>----- Please select -----<SELECTED>"
	For i = 1 To vc.count
		Set entry=vc.GetNthEntry(i)
		Print "<OPTION>" + Cstr(entry.ColumnValues(1))
	Next
	Print "</SELECT><BR>"
	Print "</BODY></FORM></HTML>"
End Sub

This was first published in September 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.