Results 1 to 2 of 2

Thread: php

  1. #1
    Join Date
    Jan 2005
    Posts
    362

    Unanswered: php

    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
    Join Date
    Jan 2005
    Posts
    362
    I test the code as
    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?

Posting Permissions

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