Jump to content

dynamic text box


royaltysaab

Recommended Posts

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>

 

Link to comment
https://forums.phpfreaks.com/topic/42977-dynamic-text-box/
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/42977-dynamic-text-box/#findComment-208764
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/42977-dynamic-text-box/#findComment-208849
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/42977-dynamic-text-box/#findComment-210403
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/42977-dynamic-text-box/#findComment-212835
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.