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

    Join Date
    Feb 2003
    Rep Power

    Need help inputing javascript value into php db query

    i need to put the value of the 'chosen' javascript variable into a php db query. For the life of me I can't figure it out! It can't be that difficult to do. Any help is truly appreciated.

    <script language=javascript>
    function setOptions(chosen) {
    var typebox = document.myform.type;
    typebox.options.length = 0;

    if (chosen == "null") {

    selbox.options[selbox.options.length] = new Option('',' ');

    if (chosen != "") {

    $query3 = "SELECT DISTINCT type FROM restaurants where city = '//need JavaScript chosen variable to go here'";
  2. #2
  3. Moderator Emeritus
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Austin, TX
    Rep Power
    I think you would need a common access point for both JS and PHP to get the variable value from... easiest method off the top of my head would be to have the variable in the URL (possibly submit the page to itself, GET the variable into the URL w/ JS) and then use $_GET['variable'] w/ PHP...

    Its just a guess, tho... don't exactly know what your code is up to. Hope it leads you in the right direction, tho.

IMN logo majestic logo threadwatch logo seochat tools logo