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

    Join Date
    Sep 2002
    Posts
    57
    Rep Power
    13

    PHP variable not being passed in javascript


    I am having a problem carrying a PHP variable through using JavaScript. I have two iframes on my page and in the first frame is the search forms while the 2nd displays your results. When I enter the search criteria and post it, I have both frames being updated, but I am not able to get the values to carry over.

    This is what I have so far:

    FRAME ONE:
    <iframe id="searchLayer" name="searchLayer" scrolling="no" width="210" height="400" frameborder="0" marginheight="0" marginwidth="0" src="searchprice.php"></iframe>
    SEARCHPRICE.PHP:

    <script language="javascript">
    var price_id=<?= $price_id ?>
    function loadframe()
    {
    parent.searchLayer.location.href='searchtype.php?price_id='+price_id
    }
    </script>

    <form action="browseprice.php" target="browseLayer" method="post" onsubmit="return loadframe('')" name="search">
    <select class="formfield" name="price_id" id="price_id">
    <option class="formfield" value="4">$75,000.00 to $100,000.00</option>
    <option class="formfield" value="7">$150,000.00 to $200,000.00</option>
    <option class="formfield" value="8">$200,000.00 to $250,000.00</option>
    <option class="formfield" value="12">$400,000.00 to $450,000.00</option>
    <option class="formfield" value="13">$450,000.00 to $500,000.00</option>
    </select>
    </form>

    FRAME TWO:
    <iframe id="browseLayer" name="browseLayer" scrolling="yes" width="550" height="400" frameborder="0" marginheight="0" marginwidth="0" src="results.php"></iframe>
    When I select a price in the search price frame and click to search, in frame two the results are displayed, and the search type [frame one] is reloaded but my price_id isn't displaying my price_id but instead displaying function loadframe(){parent.searchLayer.location.href='searchtype.php?price_id=' price_id}
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Barcelona
    Posts
    133
    Rep Power
    13
    var price_id=<?= $price_id ?>
    should be
    var price_id="<?= $price_id ?>"

    You may need the html tags too, but it might work w/o them

IMN logo majestic logo threadwatch logo seochat tools logo