PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Ive written a simple code in which a person has to select the range for two factors and click submit. a value is associated with the two values. Their sum is printed. My requirement is after the submit is clicked, the range that was selected for two questions should be displayed as it is instead of displaying the default selection. can someone help me on this.
<html>
<head>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
</p>
<p> </p>
What is the range of ABC
factor<select name="value1">
<option value=2>Low
<option value=5>Medium
<option value=10>High
</select></div>
</p>
</p>
<p> </p>
What is the range of DEF
factor
<select name="value2">
<option value=2>Low
<option value=5>Medium
<option value=10>High
</select>
</p>
<p> </p>
<input type="submit" name="submit" value="Submit">
</p>
<p> </p>
</form>
</body>
</html>
<?php
if (isset($_POST['submit']))
{
$v1= $_POST["value1"];
$v2= $_POST["value2"];
$v5 = $v1 + $v2;
echo "According to the selections that you have made the value is $v5";
}
?>
function BuildSelectBox($sel_option,$name,$options) // $options is an array
{
// output select box, loop through options
// if current options is sel_option then put 'SELECTED'
}
Then when you get the $_POST variable for your select box value, call the function with that value