aarbrouk Posted March 26, 2009 Share Posted March 26, 2009 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: <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><p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/151242-populate-a-text-field-via-mysql-drop-down/ Share on other sites More sharing options...
redarrow Posted March 26, 2009 Share Posted March 26, 2009 can you show a link to the JavaScript example please, Dont quit get you, so sorry. Link to comment https://forums.phpfreaks.com/topic/151242-populate-a-text-field-via-mysql-drop-down/#findComment-794474 Share on other sites More sharing options...
aarbrouk Posted March 26, 2009 Author Share Posted March 26, 2009 what do you mean? This javascript in the head? <script language=Javascript> function Choice() { form1.users2.value = form1.users.value; } </script> Link to comment https://forums.phpfreaks.com/topic/151242-populate-a-text-field-via-mysql-drop-down/#findComment-794490 Share on other sites More sharing options...
redarrow Posted March 26, 2009 Share Posted March 26, 2009 example of the JavaScript via the link u got, i need to see what your doing. show me the example, you got the idea from' Link to comment https://forums.phpfreaks.com/topic/151242-populate-a-text-field-via-mysql-drop-down/#findComment-794495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.