SitePoint Sponsor

User Tag List

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

    javascript and echo problem

    I want to echo some $_get variables insede a javascript function.
    But as I notice I can not use the echo inside the javascript tag.
    Code:
    <?php
    $a=$_REQUEST['country'];
    print ($a);?>
    <script type="text/javascript">
    
        function orderby()
        {
           
            alert ('<?php
    $a=$_REQUEST['country'];
    print ($a);?>')
        }....
    The $a is not there at alert!
    What is wrong?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)

  3. #3
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I post it here too because is also php related (I thing more.)

  4. #4
    SitePoint Evangelist priti's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dimis283 View Post
    I want to echo some $_get variables insede a javascript function.
    But as I notice I can not use the echo inside the javascript tag.
    Code:
    <?php
    $a=$_REQUEST['country'];
    print ($a);?>
    <script type="text/javascript">
    
        function orderby()
        {
           
            alert ('<?php
    $a=$_REQUEST['country'];
    print ($a);?>')
        }....
    The $a is not there at alert!
    What is wrong?

    you want to Echo in javascript ???

    what exactly you are trying to do?

    According to me you want $_REQUEST['capital'] passed in java script function ?

    then it is doable... onclick="call_to_function($_REQUEST['capital']"/>

    and you can use this passed var in javascript to print .

    I hope it helps .

    Thanks


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
  •