Hi All,
I'm quite new to PHP/MySQL and I'm trying to create a Job Card for our company. I have created a page with a MySQL/PHP dropdown which works great, but I need to populate the text box with the dropdown selection.
I have found a few examples using Javascript, but none of them seems to work. Am I doing something wrong or missing something. Below is my code:
Code:<html> <head> <title>Job Card</title> <script language=Javascript> function Choice() { form1.users2.value = form1.users.value; } </script> <?PHP // Make Connection include 'dbconfig.php'; // Retreive data from database mysql_connect($dbhost2, $dbuser2, $dbpass2) or die(mysql_error()); mysql_select_db($dbname2) or die(mysql_error()); $user_query = "SELECT concat(first_name, ' ', last_name) as fullname FROM users ORDER BY first_name"; $user_result = mysql_query($user_query); $client_query = "SELECT name FROM accounts ORDER BY name"; $client_result = mysql_query($client_query); ?> </head> <body> <Form name ="form1" Method ="POST" Action ="submitform.php"> <p>Please Select a User:<br> <Select Name = "users" onChange='Choice();'>User Name:</Option> <?php while ($row = mysql_fetch_array($user_result)) { echo '<Option value="'.$row['id'].'">'.$row['fullname'].'</Option>'; } ?> </Select> <p><Input Type ="text" id="users2" name="users2"> <p><Input Type ="Submit" Value ="Submit" Name ="submit" > </Form> </body> </html>



Reply With Quote
Bookmarks