Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-06-2005, 04:32 PM   PM User | #1
PeteN75
New to the CF scene

 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
PeteN75 is an unknown quantity at this point
PHP<--->Javascript<--->Access

Dear Everyone,

Briefly I am facing the following trap:
I want to do a drop-down listing users. Having selected one, text fields should be immediately filled with relevant data found in MS Access database file. The problem is Ive got then resulting values in $row['Nev'], $row['Emailcim'], $row['Beosztas'], $row['Mellek'] but I can not pass them to javascript to put it back into the form appropriate fields.

Any suggestions or help?

Any advices are welcome to <== MY EMAIL ADDRESS ==>

PeteN

The code follows here:

function kivalaszt(elem_Nev, elem_Emailcim)
{
window.document.urlap.Nev.value = elem_Nev;
window.document.urlap.Emailcim.value = elem_Emailcim;
window.document.urlap.Beosztas.value = "";
window.document.urlap.Mellek.value = "";

}
</script>

<?
require_once('odbc.php');
extract ($_POST);
if (isset($_POST['submit']))
{
$futtatas = odbc_exec($kapcsolat, "INSERT INTO Probatabla (Nev, Emailcim, Beosztas, Mellek) VALUES ('$Nev','$Emailcim','$Beosztas','$Mellek')");
odbc_close($kapcsolat);
?>
<meta http-equiv="refresh" content="0; url=index.php">
<?
} else {
?>

<form name="urlap" method="POST" action="<?$_SERVER['PHP_SELF']?>">
<table border="2" align="center">
<tr>
<td colspan="2" align="center">
<select align="CENTER" name="lista" onChange="kivalaszt(window.document.urlap.lista.options[selectedIndex].text)">
<?
$eredmeny = odbc_exec($kapcsolat, "SELECT * FROM Probatabla");
?> <option value=""> <?
while ($row = odbc_fetch_array($eredmeny))
{
?> <option value="<? print $row['Nev'];?>">
<? print $row['Nev'];?>
<?
}
?>
</option>
</select>
</td>
</tr>
<tr>
<td> <font face="ARIAL" size=3>Név: </td>
<td> <input type="text" name="Nev" size="30"></td>
</tr>
<tr>
<td> <font face="ARIAL" size=3>E-mail cím: </td><td><input type="text" name="Emailcim" size="30">
</tr>
<tr>
<td> <font face="ARIAL" size=3>Beosztás: </td><td><input type="text" name="Beosztas" size="30">
</tr>
<tr>
<td> <font face="ARIAL" size=3>Mellék: </td><td><input type="text" name="Mellek" size="30">
</tr>
<tr>
<td colspan="2" align="center" height="40">
<input type="submit" name="submit" value="Adatok módosítása">
<input type="button" value="Visszalépés" onclick="history.back()">
</tr>
</table>
</form>
<?
}
?>

</body>
</html>
PeteN75 is offline   Reply With Quote
Old 07-07-2005, 02:26 PM   PM User | #2
nikkiH
Senior Coder

 
nikkiH's Avatar
 
Join Date: Jun 2005
Location: Near Chicago, IL, USA
Posts: 1,973
Thanks: 1
Thanked 32 Times in 31 Posts
nikkiH is on a distinguished road
Does this help?
http://www.ipwebdesign.net/useful_dynamicSelectsDB.html
__________________

If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
Bored? Visit
http://www.kaelisspace.com/
nikkiH is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:46 AM.


Advertisement
Log in to turn off these ads.