royaltysaab Posted March 16, 2007 Share Posted March 16, 2007 Hi, Been trying to do this for a while, but not getting anywhere!! Tried to search for it but nothing. I'm new to PHP so apologies now for errors: Trying to create a form; when the users selects his/her username from the drop down list the textbox below populated the users email address. The information is stored in a MySQL DB called helpdesk_test, table called name userdetails. The table holds: Userid username ufirstname usurname uemail I probably have to code some javascript, but dont know how to! Can someone help please? Thanks My PHP, so far.... <?php /* Get all the required files and functions */ include('connectionstring.php'); $db2=mysql_connect($MySQLServerName2, $MySQLUserName2, $MySQLPassword2); mysql_select_db($MySQLDBName2,$db2); ?> <form method="POST" action="submit_ticket.php" name="form1" enctype="multipart/form-data"> <table border="0" cellspacing="0" cellpadding="5" size="750"> <tr> <td> <!--<input type="text" name="name" size="25" maxlength="30"></td>--> <!-- Contact info --> <table border="0"> <tr> <td align="right" width="150"><?php echo $hesklang['name']; ?>: <font class="important">*</font></td> <td align="left" width="600"><select name="name"> <?php $query = ("SELECT * FROM `userdetails` order by `userid`"); $DatabasecountQuerys = mysql_query($query,$db2); while ($row = mysql_fetch_array($DatabasecountQuerys)) { echo "<option value='$row[0]'>$row[1]</option>"; } ?> </select> </tr> <tr> <td align="right" width="150"><?php echo $hesklang['email']; ?>: <font class="important">*</font></td> <td align="left" width="600"><input type=text name="email" size="50" maxlength="80"></td> Quote Link to comment Share on other sites More sharing options...
Daleeburg Posted March 16, 2007 Share Posted March 16, 2007 Just a though. you could save the coding of a new page by having it so when you pick a user name it will refresh the page with the user name set as a variable, then the page would use a If(isset) statement and pull up the user email and such based on the variable which is the user name. ~d Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted March 16, 2007 Share Posted March 16, 2007 would you like the users to be able to just select a name from the dropdown menu and then immediately have the textbox populate the emails? or would you like the users to select from a dropdown menu, then click 'Submit', then have the textbox populated? this will be the difference between all javascript, some javascript and some php, or all php. Quote Link to comment Share on other sites More sharing options...
christophe Posted March 16, 2007 Share Posted March 16, 2007 have a look at this http://www.w3schools.com/ajax/ajax_database.asp Does it help? Thanks Alex Quote Link to comment Share on other sites More sharing options...
royaltysaab Posted March 19, 2007 Author Share Posted March 19, 2007 Thanks for all your replies: Daleeburg- i already through of that - may have to implement it, if the below don't work. boo_lolly - I would like the users to be able to just select a name from the dropdown menu and then immediately have the textbox populate the email. christophe - I'm trying this now, looks very good! I'llet you all know how i get on. thanks again. Quote Link to comment Share on other sites More sharing options...
royaltysaab Posted March 22, 2007 Author Share Posted March 22, 2007 Hi All, The AJAX solution works brilliantly!! Thanks. What i have done is, in my drop down i've got usernames, when 1 is selected a table is displayed, which shows the following information: Firstname (firstname) Surname (surname) Email (email) Login (sername) ID (id) ext (tel) Mobile (mobile) Department (depart) What i want to know is can parse the values from the generated table into another form, when the user hits submit? I can POST the drop down list, called users, but not the values of the tables. Will i have to create text boxes which populate when a value is selected from the drop down list? Quote Link to comment 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.