Domino Upgrade

VersionSupport end
5.0
6.0
6.5
7.0
Upgrade to 8.5x now!
(see the full Lotus lifcyle) To make your upgrade a success use the Upgrade Cheat Sheet. Contemplating to replace Notes? You have to read this!

Search

Reference

1. Learn XPages online
2. Communicate with IBMers and Lotus Experts using Sametime

About Me

I am the "IBM Collaboration & Productivity Advisor" for IBM Asia Pacific. I'm based in Singapore.
Reach out to me via:
Follow notessensei on Twitter
(posts)
Skype
Sametime
IBM
Facebook
LinkedIn
XING
Amazon Store
Amazon Kindle

Mobile tag

Twitter

Languages

Other languages on request.

Visitors

Useful Tools

Get Firefox
Use OpenDNS
The support for Windows XP is coming to an end and has . Time to consider an alternative to move on. sounds like a lot of time, but, like an object in a mirror, it is closer than you think.

« Workflow and Document Access | Main| More on eMail Retention »

Generating a dynamic questionaire

QuickImage A developer recently asked me how to generate dynamic questions. Dynamic as in: there is a general topic and then details. E.g.
Please state the number of building blocks per shape
ShapeRedBlueYellow
Triangle564
[Button: add row]
The filled in cells would have entry fields (not just text). So how would one do that in Domino 7 or 8 (so no XPages)? It is actually not that hard. Use a form "ConfigureQuestion" to capture all the parameters. I would have a text-area for the question (call it question) and one for the column headers (call it qdimensions). The nice trick: use a hidden regular field and construct the text-area with passthu html. The qdimensions field would be multi-value. Have a dropdown list (call it qType) with the data type. Use dijit names as alias. e.g. Text|dijit.form.TextBox. This way you will be able to generate properly validated stuff. Then have a field for width (qwidth), the first column text (qCol1) and question number (qnumber). Then have a hidden field that puts all together:
tmpCount := @Elements(qdimensions)+1;
tmpNum := "0":"1":"2":"3":"4":"5":"6":"7":"8":"9";
colCount := @Subset((tmpNum*+tmpNum);tmpCount);
tmpStart := "<table id=\"qtable"+qnumber+"\"> <tr> <th colspan=\""+tmpCount+"\" >"+question+"</th> </tr><tr>";
tmpHeader := "<th>"+qdimensions+"</th>"<;br /> tmpLineStart := "</tr><tr> <td><input type=\'text\' id=\"row1col1\" /> </td>"
tmpQuestions := "<td><input type=\"text"\ dojotype=\""+qType+"\" title=\""+qdimentions+"\" id=\"row1col"+colCount+" /> </td>";
tmpLineEnd := "</tr>"
tmpEnd := "<tr> <th colspan=\""+tmpCount+"\" ><input type=\"button\" value=\"Add Row\" onClick=\"addRow('qtable"+qnumber+"')\" / ></th> </tr>"
@Implode(tmpStart:tmpHeader:tmpLineStart:tmpQuestions:tmpLineEnd:tmpEnd;@NewLine)

The code is a rough outline, so cut and paste might not work and you also might need to work on the ids for the input fields. But you get the idea. The trick here: the multi-value field qDimensions creates as many th/td/input as we actually need. The questionnaire form would have an embedded view showing that hidden field as passthru html, so you get all questions rendered. A JavaScript function addRow(id) takes the ID of the table as parameter, so you know what table to use. Last stop: make the questions submit to an agent, so you can process all the fields.

Comments

Gravatar Image1 - Hi Tim,

I'd be interested too. Could you pass on your email address?

Gravatar Image2 - Hi

I have a fully function web survey system that I developed for the company and which we use regularly. If you want a copy, email me.

Regards

Post A Comment

Please note: Comments without a valid and working eMail address will be removed. This is my site, so I decide what stays here and what goes.

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)

Disclaimer

This site is in no way affiliated, endorsed, sanctioned, supported, nor enlightened by Lotus Software nor IBM Corporation. I may be an employee, but the opinions, theories, facts, etc. presented here are my own and are in now way given in any official capacity. In short, these are my words and this is my site, not IBM's - and don't even begin to think otherwise. (Disclaimer shamelessly plugged from Rocky Oliver)
© 2003 - 2012 Stephan H. Wissel - all rights reserved as listed here: Creative Commons License
Unless otherwise labeled by its originating author, the content found on this site is made available under the terms of an Attribution/NonCommercial/ShareAlike Creative Commons License, with the exception that no rights are granted -- since they are not mine to grant -- in any logo, graphic design, trademarks or trade names of any type.