seanfacer@yahoo.co.uk Posted September 7, 2010 Share Posted September 7, 2010 Ive tried to create a function to create a dropdown select box but im getting alot of errors to do with the if statement saying the ($_POST[$name]) value is not set??? function selectBox($name, $firstvalue, $limit, $increment) { // echo "<br>"; // echo $name; // echo "<br>"; // print_r($_POST[$name]); // echo "<br>"; $select ="selected=\"selected\""; $body = "<select name='$name' id='$name' method='POST'> <option value=''>$name</option>"; for ($value = $firstvalue; $value <= $limit; $value += $increment) { $body .= "<option value= '$value' "; if ($_POST["$name"] === $value) { $body .= $select; } $body .= ">$value</option>"; } $body .= "</select>"; // echo $value; // echo $_POST[$name]; // echo $_POST['Width']; return $body; } Any help would be greatly appreciated Quote Link to comment Share on other sites More sharing options...
coupe-r Posted September 7, 2010 Share Posted September 7, 2010 Well, you should be posting a var like that. Do this: $name = $_POST['name_txt']; name_txt is the name of the text box where they enter their name. Then you can just echo $name; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.