Q
Problem solve Get help with specific problems with your technologies, process and projects.

How do I access a dynamically generated field on the Web through LotusScript?

How do I access a dynamically generated field on the Web (using <input name="somename" value="somevalue">) through LotusScript?

To make my question clear, here is one of Dave Hatter's responses from SearchDomino.com to a similar question.

Question:
This question is regarding Domino Development. I want to create a set of fields on the fly for input in a form if the user clicks an action button.

Answer:
On the Web, this is fairly simple. You can create a LotusScript or Java agent that dynamically generates the HTML for the page. I use this particular approach all the time.

Generating the HTML is a lot easier than figuring out what to do with the information after the user submits the form. If you post it to a ?CreateDocument URL, then if the field name doesn't appear on the Notes form, the Domino server will reject the submission. On the other hand, if you put every field on the form that you're generating HTML for, then you defeat the purpose of generating the HTML dynamically.

One way to manage this is by generating HTML that contains two <FORM> tags. For instance, let's say your dynamically generated HTML is a table with three columns and an indeterminate number of rows. The field names are of the form A1, B1, C1, A2, B2, C3 and so on. Since there are no such fields on the Notes form, you want to store the data in the multivalue fields A, B and C in the document. In the default form that Domino creates in the HTML, you include hidden fields A, B and C (either via passthru or by selecting the form option to "generate HTML for all fields"). Then you use passthru to put out a </FORM> tag, and follow that with a new <FORM> tag that is set up such that the user cannot submit it. After that, put your dynamically generated fields, then a </FORM>.

On the first form, write JavaScript "onsubmit" event that harvests the data from the dynamically generated fields in the second form and assigns the hidden multivalue fields A, B and C. Assuming that there are not validation issues with this data, the onsubmit event will then allow the submission to proceed. Since you are submitting the first form, the names of the dynamic fields will not be sent to the server, but the data you copied from them will be. This is a good way to work with a table of information, since having lots of separate fields makes it impossible to display all the values with simple formulas on the form or in a view.

Another alternative is to have just one

tag, but do not submit it to a formName?CreateDocument URL command -- instead, submit it to an agentName?OpenAgent URL. The agent can read the RequestContent CGI variable from the context document and parse that information to get the field values that were submitted. The sample database you can download here contains an example of this approach.

Dig Deeper on LotusScript

SearchWindowsServer

Search400

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury

SearchDataCenter

SearchContentManagement

Close