#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    37
    Rep Power
    14

    Question PHP and Javascript Combined


    Hi,

    I'm working on a Javascript to update 2 listboxes with values, here's where PHP come in. I use PHP to get the values from a Database, but how can I use Javascript variables in PHP code?
    What I'm trying to do looks something like this simplified:

    <SCRIPT LANGUAGE="Javascript">
    function getPerioder(selection)
    {
    var ftgID = selection.options[selection.selectedIndex].value;
    <?php $result2=mysql_query("SELECT * FROM FtgPerioder WHERE ftgID=ftgID");
    $object=mysql_fetch_object($result2);
    $name=$object->name;
    ?>
    document.form1.perioder.options[0].text=name;
    }
    </SCRIPT>


    The thing I want to do is:
    replace ftgID in
    mysql_query("SELECT * FROM FtgPerioder WHERE ID=ftgID");
    with the javascript variable

    Help Greatly needed!
    Many Thanks!
    Jonas VersÚn
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Sweden
    Posts
    61
    Rep Power
    14
    Since PHP is a server-side, it has already done it┤s work when the html page is up (Javascript is client-side). So what you have to do is to run the script again with the new value.

    //N.B

IMN logo majestic logo threadwatch logo seochat tools logo