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

    Join Date
    Jul 2001
    Posts
    21
    Rep Power
    0

    JavaScript/PHP interaction problem


    I'm having trouble getting data to "echo" within JavaScripts.

    Example:
    PHP Code:
    <td onmouseover="this.style.backgroundColor='#cbddfe';this.style.cursor='hand';" onmouseout="this.style.backgroundColor='#dddddd';" onclick="location.href='./main.php?temp=<? echo $temp?>'">Home</td>
    The variable is not being printed onto the page.

    Another example:
    PHP Code:
    <td align="center"><a onMouseOver="return(updateButton('Home','Home','Active',false))" onMouseOut="return(updateButton('Blank','Home','Inactive',false))" href="./main.php?temp=<? echo $temp?>"><img src="./graphics/40/home.gif" name="buttonHome" border="0"></a></td>
    However, where just a standard link appears, the variable is printed just fine:
    <a href="./main.php?temp=<? echo $temp; ?>">Home</a>


    So, I can only assume the JavaScripting is causing some sort of trouble with the PHP. Is there anyway way around this? How can I have my variables which the page receives via a query string printed in the URLs of the links to complete those query strings?
  2. #2
  3. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    16
    nope.

    javascript, can not at all trouble PHP. PHP is parsed on server side before javascript can even come to picture.

    btw this code you have put up from your php file ??
    i think it should work.

    jd
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org
  4. #3
  5. No Profile Picture
    aHVoPw==
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2001
    Posts
    1,058
    Rep Power
    15
    you mean it's printing exactly this?
    <a href="./main.php?temp=<? echo $temp; ?>">Home</a>

    make sure php is being parsed by the server for that page. other than that, it should've worked..

    just for fact, i like to make short echo's like "<?=$temp?>"
    It just looks better.
    Visit my new IIS Tutorial Series!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2001
    Location
    Pittsburgh PA USA
    Posts
    137
    Rep Power
    16
    I had similar problems recently. However the solution was in correcting my HTML which had gotten out of whack so the javascript could find its targets.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2001
    Posts
    21
    Rep Power
    0
    jdk is right, it has nothing to do with the java, It can't. I don't know what I was thinking, just deperately trying to find a solution, I guess.

    It just so happens that all the places the variable is supposed to be printed happen to be in JavaScripts.

    It is just blowing my mind... The page is called with a query that defines the variable. I know it is successfuly received because it uses that variable to inculde it's template. The template itself calls for the variable a few more times, to be printed within the query strings of a few links. It does not appear, the url appears, but the variable is not printed. However The template calls a page which contains all the navigation links. That page should also print the variable into the strings, and it DOES.

    That is the confusing part. I can't figure out how the variable is used to incude a page and does. The variable is not recognized on the included page, but IS recognized on the page that it includes.

    It is set as a global variable:

    <?
    global $temp;
    ?>

    And to make matters worse, I have 9 templates so that people can select skins, and on 2 of the 9 skins, everything works fine. I swear there is no difference in how I set up all the templates. I wrote all the PHP on the first template, then copied and pasted it onto the other eight, and the original is one of the ones not working.

    It must be some stupid and frustrating simple little error on my part, I'll figure it out sooner or later.

IMN logo majestic logo threadwatch logo seochat tools logo