How to Make a Multiple Choice Poll Using the mrc-Productivity Series
Add some interaction to your Web site in a few short steps!
Recently mrc began posting a poll question on its Web site each month. The poll questions are created using the mrc-Productivity Series tool suite, and its newest feature - Java servlets.
Three applications were used to create the poll
question: the CGI Maintenance Form, a summary application, and a servlet graph. Here is the method used to build a poll question that allows the user to check multiple answers.
1. Create a file using the mrc maintenance option. The number of fields in that file is determined by the number of possible
answers to your poll
question. Descriptions for those fields are equal to possible answers. See Figure1 for field description.
 Figure 1 Click on image to view larger screen shot
2. When multiple answers are checked, a value of "1" is written to each checked field and then a record is written to a file. In order to summarize those fields (assuming you want to graph one record that will contain all summed fields) you need to create a static field with a default value. (See Figure 2: Value "A" is used in this example). Select R8 (Web/CGI) Form Maintenance for client/server option. Make sure you specify "O" for creating only client/server option and not B&G screen application. Now, run your application.
 Figure 2 Click on image to view larger screen shot
3. Create a summary application over the file you created in step 1. Select all the fields from that file. Make sure that when you are selecting fields, all answers filed are type S fields - meaning that you are
summing only those fields. The static field is not a summed field. Sequence by the static field and subtotal Yes on that field only. Now, run your summary application.
4.Create a retrieval/graph application that will run over your summary application to graphically represent your poll results.
Select R8 (Web/Servlet)
Graph for your
client/server option.
 Figure 3 Click on image to view larger screen shot
5. Create an external object that will submit a summary application after you add a record to your maintenance application.
The following is the source code for such an external object:
PGM
MRCSUM SUMNUM(XXXXX) DCTLIB(DICTIONARY) JQO(O)
ENDPGM
Where:
XXXXX is your summary application number, and DICTIONARY is your dictionary name where your summary application resides.
6. Compile external objects and use option 44 - Work with External objects-to add it to your data dictionary. (You don't need to specify any parameters for that external object)
7. Go back to your maintenance application and select the external object you created in step 4. (Option 8 - External objects).
Make sure you are calling it after adding the record to the database in template location (*AFTERADD). See Figure 4.
 Figure 4 Click on image to view larger screen shot
8. Recompile your maintenance application. You are now ready to "paint" your poll question. The following is the HTML source code that was used to create our September Poll Question. You can see that each field has a predefined value of 1. When a user checks the answers, 1 is written to an answer field. Those fields are then summarized in the summary file.
Additionally, the link to the servlet graph is included in the following HTML source code:
< p align="center" class="nem">Take Our Poll
< p align="center" class="ntext">Which technologies are you planning to use or already using in your business today? (check all that apply)
< p class="ntext">
< INPUT type="hidden" name="K001" value="A">
< INPUT TYPE="radio" NAME="K002" VALUE="1">CGI
< INPUT TYPE="radio" NAME="K003" VALUE="1">Java
< INPUT TYPE="radio" NAME="K004" VALUE="1">XML
< INPUT TYPE="radio" NAME="K005" VALUE="1">WML
< INPUT TYPE="radio" NAME="K006" VALUE="1">RPGIV
< !- You can add link to a Servlet Graph here ->
< center>< INPUT TYPE="submit" VALUE="Vote">< INPUT TYPE="reset" VALUE="Reset">< /center>
< INPUT type="hidden" name="KENDCD" value='J'>
< /p>< /FORM>
< p align="center" class="ntext">
< !- Link to Servlet Graph ->
< a href="http://www.mrc-productivity.com/mrcjava/servlet/MRCWEBSITE.G05112s">View Results< /a>
< a href="/pollarchive.html">View Poll Archive
NOTE: You can also SmartLink your CGI maintenance application to the servlet graph.
|