<?
require("form.inc");
require("formextra.inc");
$TestForm = new Formextra;
#These are the options for the multipleselectbox
$Options = array(0 => "Select your numbers", 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five",
6 => "Six", 7 => "Seven", 8 => "Eight", 9 => "Nine", 10 => "Ten");
if ($Submit)
{### The method returns the selected values as a string $STrefwoord1, with values delimited by a semicolon
$NumbersArray = explode(";", $STrefwoord1);
### This piece returns the selected values as strings, so they can be displayed when the form has been submitted
foreach($NumbersArray as $Number)
{
reset($Options);
while(list($Key, $No) = each($Options))
{
if ($Number == $Key && $Number != 0)
{
$DivStuff .= $No."<br>";
}
}
### This makes the lovely grandtotal =P
$GrandTotal = $GrandTotal + $Number;
}
}
$TestForm -> StartForm("Testje", $PHP_SELF);
$TestForm -> AddHTML("This is the multiple select. <br>Select once to select, select twice to deselect.",
"LabelSelect", "Label");
/*Following line is the main thingy in this script. First parameter is the CSS id the selectbox'll get
second parameter is the list of options and values to be shown, third parameter is the name of the
form the selectbox'll be placed in, the fourth option is an array of selected values, fifth option
is number of the selectbox, if multiple selectboxes are used in one form, the sixth option is the
string to be printed as selected options*/
$TestForm -> MultipleSelectBox("MultipleSelectBox", $Options, 'Testje', $NumbersArray, 1, $DivStuff);
$TestForm -> Submit("Submit", "Submit");
$TestForm -> EndForm();
?>
<!-- Here we can start the HTML and print the PHP objects. I like to keep the main body of PHP
and the HTML page separated for those poor webdesigners =) -->
<body>
<script>
<?print $TestForm -> JavaScript?>
</script>
<!-- Following is the format of the shown options (one, two three etc)
The CSS id for this div tag is always Trefwoorden + the number of the
selectbox on the page -->
<style>
#Trefwoorden1
{
position: relative;
left: 175px;
bottom: 20px;
height: 75px;
}
</style>
<html>
<?print $TestForm -> RawHTML;
if ($Submit)
{
print "
You selected a grand total of $GrandTotal! <br>\n
Congratulations!";
}
?>
</html>
</body> |