SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ajax and $_get values problem

    I have a page with a list of products that belongs to a category (The id of the gategory if $_get('cat')).
    I use also prototype and ajax updater (with get method) to get the results for a form that has this page.
    My problem is that I want to get at a javascript function the 'get' variables of the page to reuse them.
    I write
    Code:
    <script type="text/javascript">
        function orderby()
        {
            var a='<?php  if (!empty($_GET['country']))
                {   
      echo
     "country=$mycountry&producer=$myproducer";
                }
                else
                echo "cat=$thiscat";
                ?>';
    
                    }
    when $_GET['country'] is a element of the form but it does not work.
    How Can I get the 'get' elements and reuse them at javascript?

  2. #2
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I test the code as
    Code:

    Code:
    <?php $a=$_REQUEST['country']; print ($a);?>
     <script type="text/javascript"> function orderby() 
    { alert ('<?php $a=$_REQUEST['country']; print ($a);?>') }
    ....
    The $a is printing before javascript code but it is not at the alert message what is wrong?

  3. #3
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,508
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Look at the code that arrives at your browser. How does the javascript look?


Bookmarks

Posting Permissions

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