2005-10-24 17:59:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function step2_do () {
|
|
|
|
global $election;
|
2005-10-24 18:25:43 +00:00
|
|
|
global $choices_nb;
|
|
|
|
global $choices;
|
2005-10-24 17:59:15 +00:00
|
|
|
global $vote;
|
|
|
|
global $votes_array;
|
|
|
|
|
|
|
|
$result = "<h2>Step 2/4 - Choose your vote</h2>\n";
|
|
|
|
|
|
|
|
$result .= "<p><strong>".$election["question"]."</strong></p>\n";
|
|
|
|
$result .= "<p>Possible answers:</p>\n";
|
|
|
|
|
|
|
|
$result .= "<div class=\"votedata\">\n";
|
2005-10-24 18:25:43 +00:00
|
|
|
if ($choices_nb == 1) {
|
2005-10-24 17:59:15 +00:00
|
|
|
$result .= "<p>\n";
|
2005-10-24 18:25:43 +00:00
|
|
|
foreach ($choices as $choice) {
|
2005-10-24 17:59:15 +00:00
|
|
|
$checked = "";
|
2005-10-24 18:25:43 +00:00
|
|
|
if ($choice["id"] == $vote) {
|
2005-10-24 17:59:15 +00:00
|
|
|
$checked = " checked=\"checked\"";
|
|
|
|
}
|
|
|
|
|
2005-10-24 18:25:43 +00:00
|
|
|
$result .= "<input type=\"radio\" name=\"vote\" value=\"".$choice["id"]."\"".$checked."> ".$choice["choice"]."<br />\n";
|
2005-10-24 17:59:15 +00:00
|
|
|
}
|
|
|
|
$result .= "</p>\n";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$result .= "<p>\n";
|
2005-10-24 18:25:43 +00:00
|
|
|
foreach ($choices as $choice) {
|
2005-10-24 17:59:15 +00:00
|
|
|
$checked = "";
|
2005-10-24 18:25:43 +00:00
|
|
|
if (in_array ($choice["id"], $votes_array)) {
|
2005-10-24 17:59:15 +00:00
|
|
|
$checked = " checked=\"checked\"";
|
|
|
|
}
|
|
|
|
|
2005-10-24 18:25:43 +00:00
|
|
|
$result .= "<input type=\"checkbox\" name=\"vote".$choice["id"]."\"".$checked."> ".$choice["choice"]."<br />\n";
|
2005-10-24 17:59:15 +00:00
|
|
|
}
|
|
|
|
$result .= "</p>\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
$result .= "</div>\n";
|
2005-10-24 18:25:43 +00:00
|
|
|
if ($choices_nb > 1)
|
|
|
|
$result .= "<p><em>You can choose up to ".$choices_nb." answers.</em></p>\n";
|
2005-10-24 17:59:15 +00:00
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|