41 users online (0 members and 41 guests)  


  Results 1 to 3 of 3

Related

  1. Replies: 0
  2. Javascript function call    Forum: Javascript Forum
    Replies: 1
  3. [SPLIT]passing values to an external .js file    Forum: Javascript Forum
    Replies: 37
  4. passing values to an external .js file    Forum: Javascript Forum
    Replies: 10
  1. #1
    kitkat's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    9

    Question call external Javascript(PHP) with passing value

    Hi everyone,
    Previously I was using this code and it work perfectly fine:
    Code:
    <SCRIPT LANGUAGE="Javascript" SRC="../count.php?page=Home"><!--
           //--></SCRIPT>
    Because of some enhancement, I need to add some varaible behind the link (&from=variable). How am I going to do it?
    I tried to:
    1)
    Code:
    <SCRIPT LANGUAGE="Javascript" SRC="../count.php?page=Home&from=" + var ><!--
           //--></SCRIPT>
    2) Planning to call the file in a Javascript
    Code:
    <SCRIPT LANGUAGE="Javascript"><!--
    if ( frm == "xx") {
           <SCRIPT LANGUAGE="Javascript" SRC="../count.php?page=Home&from=xx"><!--
           //--></SCRIPT>
    }else{
           <SCRIPT LANGUAGE="Javascript" SRC="../count.php?page=Home"><!--
           //--></SCRIPT>
    //--></SCRIPT>
    All also couldn't work. Please help.

  2. #2
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: call external Javascript(PHP) with passing value

    The <SCRIPT... tag tells the parser that what follows will be a script. LANGUAGE tells the parser what language it will be, and SRC where the csript is coming from.
    Until the browser has finished parsing the whole of the <SCRIPT> tag, it is still in HTML and therefore you can't use code.

    Don't know how you'd get around this in html, but if you're generating the page from PHP you'd use
    PHP Code:
    echo "<SCRIPT LANGUAGE=\"Javascript\" SRC=\"../count.php?page=Home&from=" $var " ><!--\n";
    echo 
    "\t//--></SCRIPT>\n"

  3. #3
    kitkat's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    9

    Re: call external Javascript(PHP) with passing value

    Quote Originally Posted by DeadMeatGF View Post
    The <SCRIPT... tag tells the parser that what follows will be a script. LANGUAGE tells the parser what language it will be, and SRC where the csript is coming from.
    Until the browser has finished parsing the whole of the <SCRIPT> tag, it is still in HTML and therefore you can't use code.

    Don't know how you'd get around this in html, but if you're generating the page from PHP you'd use
    PHP Code:
    echo "<SCRIPT LANGUAGE=\"Javascript\" SRC=\"../count.php?page=Home&from=" $var " ><!--\n";
    echo 
    "\t//--></SCRIPT>\n"
    Really appreciate your help but I am not using php on my main site.

    Actually, this mainpage will call a php file to do a 'hitcount' but now I am trying to make it to skip the increament when the user is coming from a certain page. That's why other page will pass a value with "?from=xxx" in the URL when calling that mainpage. Then, this mainpage need to pass the parameter to the php file when calling the counter file(php) (as shown from my previous post for the code). When the counter(php) check the parameter, it will decide to increase or just display the number.

    Any idea other than this way?



Tags for this Thread