E
Emma
Guest
Sorry for bothering everyone with what is probably a simple problem but I'm really bad at all things web development.
I'm. trying to populate a text box with information held in my database.
It's a name, which I want to get when the user selects an ID from an option drop down box. So I have to take the selected number and use it to get the corresponding name from my database.
Here's my code so far, i know it probably doesn't make much sense but if anyone could help, I'v spent far too much time trying to understand it at this point.
<table>
<tr>
<td>
Employee Number
</td>
<td>
<select name="number">
<?php
while($row = mysql_fetch_row($result))
{
?>
<option onclick="fun1('<?php print $row[0]; ?>')" value = "<?php print $row[0]; ?>"><?php print $row[0]; ?></option>
<?php
}
?>
</td>
</tr>
<tr>
<td>
Employee First Name
</td>
<td>
<script language="JavaScript">
function fun1(num)
{
var firstName = sql_search("SELECT first_name FROM employees WHERE employee_id = something",$con);
return firstName;
}
</script>
</td>
</tr>
If anyone could help I'd be really great full
Hey, thank you all sooo much. I didn't expect an answer so fast. I think I will add a submit button. I think I know how to achieve what I'm trying to do If I use one.
Thanks again, ya's are all wee stars : )
I'm. trying to populate a text box with information held in my database.
It's a name, which I want to get when the user selects an ID from an option drop down box. So I have to take the selected number and use it to get the corresponding name from my database.
Here's my code so far, i know it probably doesn't make much sense but if anyone could help, I'v spent far too much time trying to understand it at this point.
<table>
<tr>
<td>
Employee Number
</td>
<td>
<select name="number">
<?php
while($row = mysql_fetch_row($result))
{
?>
<option onclick="fun1('<?php print $row[0]; ?>')" value = "<?php print $row[0]; ?>"><?php print $row[0]; ?></option>
<?php
}
?>
</td>
</tr>
<tr>
<td>
Employee First Name
</td>
<td>
<script language="JavaScript">
function fun1(num)
{
var firstName = sql_search("SELECT first_name FROM employees WHERE employee_id = something",$con);
return firstName;
}
</script>
</td>
</tr>
If anyone could help I'd be really great full

Hey, thank you all sooo much. I didn't expect an answer so fast. I think I will add a submit button. I think I know how to achieve what I'm trying to do If I use one.
Thanks again, ya's are all wee stars : )