Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    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

    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/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •