![]() |
Passing variables from PHP to Javascript and vice versa
i have a frames page with a menubar at top and the main content below. i want the main page to redirect to a PHP page based on screen size using the following format
if (screen.width > 1024) {window.location.href='girls1024.php?id=XXXXX'} where XXXXX will be sent to JS from PHP i know very little about JS, so help me out here... thanks :) |
uhh....
|
Your main page has to set those values. They'll be part of the html document that is sent to the browser. Since it sounds like the main page will be dynamic in nature, whatever you use to build the main page should just fill that information in as part of the html document.
|
(for this message, whenever I put "*", replace it by a "?" ... I can't write it the right way, else it treats it as php)
ok assuming your page you are linking to is called www.domain.com/redir.php you'd link to it like www.domain.com/redir.php?id=magnatique then, on that redir.php page you'd have if (screen.width >= 1024) {window.location.href='girls1024.php?id=<* echo $id;*>'} else if (screen.width >= 800) {window.location.href='girls800.php?id=<* echo $id;*>'} else {window.location.href='girls640.php?id=<* echo $id;*>'} |
uhh...
|
i tried that and it didn't work... as far as i know (and correct me if i'm wrong) you can't imbed one script in another.
Quote:
|
Quote:
|
php has to be enabled on the server ;)
also, as I said, replace the * by ? whatever you put in a url like ?id=test you call it back ('test') by writing <* echo $id;*> where the * is a ? |
Quote:
PHP Code:
PHP Code:
Rory |
Quote:
Rory |
Quote:
number two, i had originally tried it in the format you suggested, and that didn't work, so that's why i came here. you're 100% right about java being client-side and php being server-side... i thought it would work, but it didn't as for your comment rory, i'm a "newb" when it comes to javascript... not when it comes to php/c++ i'll attempt to explain my objective a bit better. i have a frames page, the top frame being a menu bar controlling the main frame. the surfer will fill out a form in the main frame and id is a unique ID assigned to them when they sign up for my site. it's the primary key of a mysql table. when the login, a script retrieves their info from the table, and ID gets plugged into a hidden form element. when they fill out the form and submit it, the form gets processed and they're brought to the javascript redirect page which redirects them based on their screen size, giving them a unique page based on their screen size and ID ------------------------------------------------- it's all moot because i've solved the problem but thanks anyways :) |
am a php newb myself, trying to learn it hehe..
thanks for the heads up rory, will code this way from now on ;) |
| All times are GMT -7. The time now is 02:58 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123