Jump to content

drop down option selected into text field


adzie

Recommended Posts

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.