Trium918 Posted March 22, 2008 Share Posted March 22, 2008 The dob function below populates the drop down menu, but there isn't any output being displayed to the screen. Why? Can someone tell me? <?php function dob() { $month = array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $select = "<select name=\"birth_month\" >\n"; $select .="<option val=\"0\">Month\n"; for ($i = 0; $i < count($month); $i++) { $val = $i+1; $select .= "<option val=\"".$val."\">".$month[$i]."\n"; } $select .= "</option></select>"; $select .=" "; $select .= "<select name=\"birth_day\">\n"; $select .="<option val=\"0\">Day\n"; for ($i = 0; $i < 31; $i++) { $val = $i+1; $select .= "<option val=\"".$val."\">".$val."\n"; } $select .= "</option></select>"; return $select; } $birth_date = dob(); echo $birth_date; $birth_month = $_POST['birth_month']; $birth_day = $_POST['birth_day']; $self = $_SERVER['PHP_SELF']; ?> <form action="<?php echo $self ?>" method="post"> <table border="1"><tr><td> <?php if (isset($_POST['submit'])) { echo $birth_month."/".$birth_day; } ?> </td></tr><tr><td> <input type="submit" value="Submit" name="submit" /> </td></tr></table> </form> Link to comment https://forums.phpfreaks.com/topic/97387-problem-with-drop-down-menu/ Share on other sites More sharing options...
Orio Posted March 22, 2008 Share Posted March 22, 2008 Is this the whole script? And there's no output at all?? (Even when you open the source of the page) Orio. Link to comment https://forums.phpfreaks.com/topic/97387-problem-with-drop-down-menu/#findComment-498340 Share on other sites More sharing options...
Trium918 Posted March 22, 2008 Author Share Posted March 22, 2008 The dob function populates the drop down menu. That part is working just fine. After the submit button is submitted, there is no data being displayed to the screen. Link to comment https://forums.phpfreaks.com/topic/97387-problem-with-drop-down-menu/#findComment-498353 Share on other sites More sharing options...
BlueSkyIS Posted March 22, 2008 Share Posted March 22, 2008 the problem is that the date <SELECT> form elements are outside of the <FORM> move echo $birth_date; to inside the <FORM> <?php function dob() { $month = array ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $select = "<select name=\"birth_month\" >\n"; $select .="<option val=\"0\">Month\n"; for ($i = 0; $i < count($month); $i++) { $val = $i+1; $select .= "<option val=\"".$val."\">".$month[$i]."\n"; } $select .= "</option></select>"; $select .=" "; $select .= "<select name=\"birth_day\">\n"; $select .="<option val=\"0\">Day\n"; for ($i = 0; $i < 31; $i++) { $val = $i+1; $select .= "<option val=\"".$val."\">".$val."\n"; } $select .= "</option></select>"; return $select; } $birth_date = dob(); $birth_month = $_POST['birth_month']; $birth_day = $_POST['birth_day']; $self = $_SERVER['PHP_SELF']; ?> <form action="<?php echo $self ?>" method="post"> <?php echo $birth_date; ?> <table border="1"><tr><td> <?php if (isset($_POST['submit'])) { echo $birth_month."/".$birth_day; } ?> </td></tr><tr><td> <input type="submit" value="Submit" name="submit" /> </td></tr></table> </form> Link to comment https://forums.phpfreaks.com/topic/97387-problem-with-drop-down-menu/#findComment-498354 Share on other sites More sharing options...
Trium918 Posted March 22, 2008 Author Share Posted March 22, 2008 val should have been value inside the option tag SOLVED Link to comment https://forums.phpfreaks.com/topic/97387-problem-with-drop-down-menu/#findComment-498447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.