The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
JavaScript/PHP interaction problem
Discuss JavaScript/PHP interaction problem in the JavaScript Development forum on Dev Shed. JavaScript/PHP interaction problem JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 1st, 2001, 01:15 AM
|
|
Registered User
|
|
Join Date: Jul 2001
Posts: 21
Time spent in forums: < 1 sec
Reputation 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?
|

October 1st, 2001, 08:05 AM
|
 |
phpkid ~~~~~~ :o)
|
|
Join Date: Nov 2000
Location: NJ, USA
Posts: 2,534
 
Time spent in forums: 11 m 11 sec
Reputation Power: 15
|
|
|
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
|

October 1st, 2001, 04:22 PM
|
|
aHVoPw==
|
|
Join Date: Jan 2001
Posts: 1,058
 
Time spent in forums: 15 h 42 m 24 sec
Reputation Power: 14
|
|
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.
|

October 1st, 2001, 08:22 PM
|
|
Contributing User
|
|
Join Date: Sep 2001
Location: Pittsburgh PA USA
Posts: 137
  
Time spent in forums: 22 h 22 m
Reputation Power: 15
|
|
|
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.
|

October 2nd, 2001, 11:06 PM
|
|
Registered User
|
|
Join Date: Jul 2001
Posts: 21
Time spent in forums: < 1 sec
Reputation 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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|