Required and Optional Pages |
MGI Tags |
|---|---|
| Overview (below) | |
| Collecting Poll Data (below) | mgiPoll |
| Displaying Poll Results (below) | mgiPoll |
Poll Instructions | Poll Example | MGI Functions
Polls and SurveysOverviewPolls allow you to gather opinions from your visitors and are an excellent marketing tool -- visitors return to your website to see the poll results and you can collect information about the preferences of your web site audience. Furthermore, since poll results are dynamically displayed from a database, your information is always up-to-date and timely -- even to the second! There are two aspects of an online poll: 1) collecting poll data and 2) displaying poll results. Using the mgiPoll tag, you can collect poll data without displaying the results of the poll, collect poll data and display the results each time a visitor submits their answers, or allow visitors to view the poll results without answering the poll question. Collecting Poll DataTo collect information from your web site visitors, create a page with the mgiPoll tag and its three required parameters: databaseFileLocation, tableName, and formatFileLocation. The databaseFileLocation parameter specifies the name of the database file where poll results will be stored. If the database file does not exist, MGI will create the file. The tableName parameter specifies the name of the database table where poll results will be stored. If the table does not exist in the database file, MGI will create the table. If the database file and table do exist, they should not contain any fields or records. MGI will automatically add fields and records to the database when the page containing mgiPoll is accessed. The final required parameter in mgiPoll is formatFileLocation. The poll format file should consist of HTML, text, and MGI tags that define the layout and content of your poll questions and answers. When displayed, the entire format file is included in the poll page, so you do not need to include complete beginning and ending HTML, HEAD, and BODY tags in the file. You may choose any design or layout for the questions and answers, except your poll answers must be formatted as radio buttons, checkboxes, or popup menus. If you choose to tally and display the poll results, the value of each radio button, checkbox, and popup menu will be displayed as the label of each answer, therefore you should enter appropriate values in the HTML for each answer. The format file for mgiPoll must contain a submit button. By default, each poll submission is posted to itself. If you prefer to present visitors with another page after their submission to display a "thank you" message or to display the poll results, you must enter HTML form tags in the format file. One set of HTML form tags should enclose all questions, answers, and the submit button. The form action is the name of the page that visitors will view after their submission and the form method should be "post". If you post poll submissions to a separate page using HTML form tags, you must enter an mgiPoll tag with the three required parameters on the target page. The mgiPoll tag must be entered on the target page because poll answers are added to the specified database and table after they are submitted (posted) to a page containing mgiPoll.
The following is an example poll page containing the mgiPoll tag and its three required parameters. <HTML> <HEAD> </HEAD> <BODY BGCOLOR="#ffffff"> <H2 ALIGN=CENTER>Poll</H2> <mgiPoll databasefilelocation="Surveys" tableName="Election2000" formatFileLocation="pollformat.txt"> <P ALIGN=CENTER><HR WIDTH="500"></P> </BODY> </HTML>
The following is an example poll format file. It contains three questions formatted in tables. Using one set of HTML form tags, poll answers are posted to the "results.html" page (shown below). <FORM ACTION="results.html" METHOD="POST"> <CENTER> <TABLE WIDTH="300" CELLPADDING="5"> <TR> <TD WIDTH="100%" BGCOLOR="#00ff00"> If you had to vote today, who would you choose to represent the Republican party in the next presidential election?</TD></TR> <TR> <TD WIDTH="100%" BGCOLOR="#ccffcc"> <P><INPUT TYPE="radio" VALUE="Pat Buchanan" NAME="Republican">Pat Buchanan</P> <P><INPUT TYPE="radio" VALUE="George W. Bush" NAME="Republican"> George W. Bush</P> <P><INPUT TYPE="radio" VALUE="Elizabeth Dole" NAME="Republican"> Elizabeth Dole</P> <P><INPUT TYPE="radio" VALUE="Other" NAME="Republican"> Other</TD></TR> </TABLE> <TABLE WIDTH="300" CELLPADDING="5"> <TR> <TD WIDTH="100%" BGCOLOR="#ffff00"> If you had to vote today, who would you choose to represent the Democratic party in the next presidential election?</TD></TR> <TR> <TD WIDTH="100%" BGCOLOR="#ffffcc"> <P><INPUT TYPE="radio" VALUE="Hillary Clinton" NAME="Democrat"> Hillary Clinton</P> <P><INPUT TYPE="radio" VALUE="Dick Gephart" NAME="Democrat"> Dick Gephart</P> <P><INPUT TYPE="radio" VALUE="Al Gore" NAME="Democrat"> Al Gore</P> <P><INPUT TYPE="radio" VALUE="Other" NAME="Democrat"> Other</TD></TR> </TABLE> <TABLE WIDTH="300" CELLPADDING="5"> <TR> <TD WIDTH="100%" BGCOLOR="#00ccff">What is your age?</TD></TR> <TR> <TD WIDTH="100%" BGCOLOR="#ccffff"><SELECT NAME="Age"> <OPTION SELECTED>18 to 25 <OPTION>26 to 35 <OPTION>36 to 45 <OPTION>46 to 55 <OPTION>56 to 65 <OPTION>over 65 </SELECT> </TD></TR> </TABLE> <INPUT NAME="name" TYPE="submit" VALUE="Submit Answers"> </CENTER> </FORM>
The following is an example target page for poll submissions (results.html in the example above). The mgiPoll tag on the target page matches the mgiPoll tag on the poll page exactly. <HTML> <HEAD> </HEAD> <BODY BGCOLOR="#ffffff"> <H3 ALIGN="CENTER">Thank you for your opinions!</H3> <mgiPoll databasefilelocation="Surveys" tableName="Election2000" formatFileLocation="pollformat.txt"> <P ALIGN=CENTER><HR WIDTH="500"></P> </BODY> </HTML> Displaying Poll ResultsTo display poll results, enter the mgiPoll tag with its three required parameters and the optional "tally" parameter on a page. To format the poll results, you may also choose to add any of the other optional parameters:
Results are displayed according to the location of answers in the format file. Each answer (radio button, checkbox, or popup menu) is replaced with the poll results for that answer (the answer value as a label, a bar graph and the data for that answer as an integer or percentage). If you want to display the poll results after a visitor has submitted their own opinions, you must enter a separate mgiPoll tag to display the results. One mgiPoll tag will not simultaneously process new poll submissions and display poll results. In the following example, poll results are displayed on the target page of poll submissions (results.html in the example above). The first mgiPoll tag processes the new poll data and the second mgiPoll tag displays the current poll results from the database. Each result will be graphed according to the answer's location in the pollformat.txt file. Each bar graph will not exceed 300 pixels in length and will be 13 pixels high. Beginning with the first result, the color of each bar graph will alternate between blue and red. <HTML> <HEAD> </HEAD> <BODY BGCOLOR="#ffffff"> <H3 ALIGN="CENTER">Poll Results</H3> <mgiPoll databasefilelocation="Surveys" tableName="Election2000" formatFileLocation="pollformat.txt"> <mgiPoll databasefilelocation="Surveys" tableName="Election2000" formatFileLocation="pollformat.txt" tally="yes" tallyresultsby="total" maximumbargraphlength="300" bargraphheight="13" colorcycle="blue,red"> <P ALIGN=CENTER><HR WIDTH="500"></P> </BODY> </HTML> |
Poll Instructions | Poll Example | MGI Functions