If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Notice that the information submitted in the form is in the nature of a javascript array, and that it could be made much larger than the two pieces of info that we send here. It could just as well have been an array built by push, or any other method. When it appears on the php side, it's just a comma separated list, and can be exploded into an identical php array, and used as such.

If you want to send a php array to javascript, the way that I've used is to push the array on the JS side by echoing push statements. That method seems to be immune to differences in data types.

Last edited by DrDOS; 08-17-2013 at 11:35 PM.
Reason: Thought of better way.

The main difference from the above solution is that the PHP script then runs completely independently of the current page which stays visible. The only other requirement is that the PHP be set to create a dummy image.

That's very interesting and I'll look into it, but right now I'm still improving my script since it does exactly what I want it to do, namely give php all the information it needs to build proper web pages, right up front. Just as a test I rewrote it so that it build the array in the submit process, and I took the style information from the index page and put it in a php page which used the information sent to set part of the style. It would be really nice to be able to particularize the style for the user without having to use javascript with inline code, and this lets you do that.

It would be really nice to be able to particularize the style for the user without having to use javascript with inline code, and this lets you do that.

The screen width and height has nothing to do with the viewport area in which the web page is to be displayed. If all you are trying to do is to style the page differently for different screen or viewport sizes then CSS can do that without needing any JavaScript at all.

The screen width and height has nothing to do with the viewport area in which the web page is to be displayed. If all you are trying to do is to style the page differently for different screen or viewport sizes then CSS can do that without needing any JavaScript at all.

I may be slightly prejudiced by the fact that my own pages are actually web applications for processing images, some of them very large, such as 4096px, so the % thing won't cut it. I have to know specific values, and so may other people. If you go to my Home page and download this month's calendar, you will see what I'm doing. Maybe next month I put up a calender from Australia?

to attach specific styles only if the viewport is 800px wide or smaller

Well, I haven't tried that, but still would it return anything to php, which would still need to know in my case? I'll learn about it, if it can re-size an image to 1/4 or 1/2 depending on screen size and tell php about it, it might be useful.