pass a variable from javascript to php
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   chris_harwood
Posted On:   Tuesday, December 9, 2003 03:21 PM

Yes I understand the difference between client-side and server-side. Examples I've found say something about hidden fields in a form and posting, just not clear enough for me. this is what I am shooting for. when the page loads, it loads the correct background image based on client resolution. the variable is a simple screen.width, no problem. What I am stuck on is this: I need that screen.width variable to be passed on to PHP in the same page. I am trying to use <?php include (filename); ?> based on that screen.width variable. I.E. <?php $var = screen.width variable passed from javascrip   More>>

Yes I understand the difference between client-side

and server-side. Examples I've found say something about

hidden fields in a form and posting, just not clear enough

for me. this is what I am shooting for. when the page

loads, it loads the correct background image based on

client resolution. the variable is a simple screen.width,

no problem. What I am stuck on is this:

I need that screen.width variable to be passed on to PHP

in the same page. I am trying to use <?php include

(filename); ?> based on that screen.width variable.


I.E.

<?php

$var = screen.width variable passed from javascript

if ($var==800){

echo (include whatever file)

}else (etc. etc. etc){

}I have found several examples, but nothing descriptive

enough. the thing is, I have probably looked at the

answer several times. My thing is, if I don't understand

what the code is doing then I don't understand what to do

to alter it for my own use. Kind of a dummy. This works

great for me.



< code blah blah blah>

//this does this

< code blah blah blah>

//this does this

< code blah blah blah>

//this does this

< code blah blah blah>

//this does this

I am kind of a beginner, yet once something is explained

good, I will be able to use any part of it from then on.

Very fast learner. Help if you can. Thanks for any time

you put into replying to me. My website that I am trying

this with is
www.midshift.net

   <<Less

Re: pass a variable from javascript to php

Posted By:   Naveed_Azhar  
Posted On:   Wednesday, December 10, 2003 04:38 AM

I think you should do this:

On the index page compute the browser variables and based on this information redirect the user to appropriate page Or
store the browser variables into the session on first page and then call another page which. On second page you can include appropriate files based on the session information.

Re: pass a variable from javascript to php

Posted By:   Firat_Tiryaki  
Posted On:   Wednesday, December 10, 2003 12:09 AM

You can communicate the server side and client side only by making a request or post, they don't (can't) know each other on the client side. Most used technique is to post some hidden vars to server side to make the server side know that the client has those vars.
About | Sitemap | Contact