adzie Posted August 15, 2007 Share Posted August 15, 2007 Is it possible once I have selected an option from a drop down box which displays information from a DB to display that chosen option in a text box? my code so far below: <?php //Connect to db $_POST['name']. include("connectdb.php"); $query = "SELECT name FROM pilots"; $result = mysql_query($query); echo "<select name=\"names\">\n"; while($row = mysql_fetch_array($result)) echo "<option name=\"".$row['name']."\">".$row['name']."</option>\n"; ?> <table width="300" cellpadding="10" cellspacing="0" border="2"> <tr align="center" valign="top"> <td align="center" colspan="1" rowspan="1" bgcolor="#64b1ff"> <h3>Edit and Submit</h3> <form action="change_form.php" method="post"> <input type="Submit" value="Update"> </form> Click Here to acces that members File </td></tr></table> Quote Link to comment https://forums.phpfreaks.com/topic/65100-drop-down-option-selected-into-text-field/ Share on other sites More sharing options...
Orio Posted August 15, 2007 Share Posted August 15, 2007 I dont really understand you - do you want to display the value that was received from page1, in page2 inside a text box? If thats the issue it's as simple as: echo "<input type=\"text\" value=\"".$_POST['names']."\">"; Orio. Quote Link to comment https://forums.phpfreaks.com/topic/65100-drop-down-option-selected-into-text-field/#findComment-324895 Share on other sites More sharing options...
adzie Posted August 15, 2007 Author Share Posted August 15, 2007 What I'd like to do is one of two things, either once I've selected a option click submit and that option appears in a text box on a new page or a text box on the same page Quote Link to comment https://forums.phpfreaks.com/topic/65100-drop-down-option-selected-into-text-field/#findComment-324901 Share on other sites More sharing options...
Orio Posted August 15, 2007 Share Posted August 15, 2007 If you want it to appear in the same page (before submitting), you'll need javascript. If you want it to appear in the next page, then use what I showed above. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/65100-drop-down-option-selected-into-text-field/#findComment-324903 Share on other sites More sharing options...
adzie Posted August 16, 2007 Author Share Posted August 16, 2007 thanks for your reply i think i'm missing something from my second page, any thoughts as they selected name does not appear on the next page <html><head><title></title></head> <body> <? echo "<input type=\"text\" value=\"".$_POST['names']."\">"; ?> <table width="300" cellpadding="10" cellspacing="0" border="2"> <tr align="center" valign="top"> <td align="center" colspan="1" rowspan="1" bgcolor="#64b1ff"> <h3>Edit and Submit</h3> <form action="change_record.php" method="post"> <input type="text" name="name" value="<?php print $_POST['name']?>"> <input type="hidden" name="password" value="<?php print $_POST['password']?>"> <input type="hidden" name="vid" value="<? echo "$vid" ?>"> Name: <input type="text" name="name" value="<? echo "$name"?>"?><br> Password: <input type="text" name="password" value="<? echo "$password"?>"?><br> <input type="Submit" value="Update"> </form> </td></tr></table> <? ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/65100-drop-down-option-selected-into-text-field/#findComment-325808 Share on other sites More sharing options...
adzie Posted August 17, 2007 Author Share Posted August 17, 2007 any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/65100-drop-down-option-selected-into-text-field/#findComment-326542 Share on other sites More sharing options...
beboo002 Posted August 17, 2007 Share Posted August 17, 2007 insted of this <input type="text" name="name" value="<?php print $_POST['name']?>"> u used this <input type="text" name="name" value="<?php echo $name; ?> " > hope fully thats work propaly Quote Link to comment https://forums.phpfreaks.com/topic/65100-drop-down-option-selected-into-text-field/#findComment-326616 Share on other sites More sharing options...
adzie Posted August 19, 2007 Author Share Posted August 19, 2007 thanks for that, still no results, anyone else got any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/65100-drop-down-option-selected-into-text-field/#findComment-328231 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.