[email protected] 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 Link to comment https://forums.phpfreaks.com/topic/212760-select-dropdown-box-function/ 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; Link to comment https://forums.phpfreaks.com/topic/212760-select-dropdown-box-function/#findComment-1108337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.