...

View Full Version : PHP<--->Javascript<--->Access



PeteN75
07-06-2005, 04:32 PM
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 ==> (nagyp@olajterv.hu)

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>

nikkiH
07-07-2005, 02:26 PM
Does this help?
http://www.ipwebdesign.net/useful_dynamicSelectsDB.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum