now before you assume that i'm a impatient/lazy newb, i'm a php newb, not a forum newb, i've used the search function, but the only match i found didn't explain it to a point where i could understand.

anyways, i'm in the middle of making my first custom php script and have hit a bit of a snag. i need a piece of data that's only ubtainable via js, but i need to know how use the variable produced in a php if/else statement:

[COLOR=Red]var monitors = app.monitors.primary();
var res = monitors[0].rect;[/COLOR]

[COLOR=Blue]<?php 
if( $[/COLOR][COLOR=Red]res[2][/COLOR] [COLOR=Blue]< 1024 &&[/COLOR] [COLOR=Red]res[3][/COLOR][COLOR=Blue] < 768)
.....
?>[/COLOR]

[COLOR=Blue]blue=php[/COLOR]
[COLOR=Red]red=javascript[/COLOR]

can anyone help?

-Samo

    Well, first of all, I have to ask -

    You realize that JS is client-side, and PHP is server-side, right? So anything you do in JS has to be transmitted back to the server before you can use it in a PHP script. This can be done through solutions such as AJAX, or simply reloading the page.

      hmmmmm, is there anyway to do it with out refreshing, like say, making the if statement javascript but the rest php?

        As I said, you'll need to look into methods that use Javascript to communicate with the server, such as AJAX. Otherwise, no. You're talking about two completely different ends of the connection here.

          ok, thx anyways

          one last quuestion, can html be used in place of xml with AJAX?

            Samo wrote:

            ok, thx anyways

            one last quuestion, can html be used in place of xml with AJAX?

            HTML isn't a scripting language, therefore it can't actually do anything, all HTML does is changes how the page looks...so no, it can't.

            I found this tutorial very useful for learning AJAX.

              then does anyone know how i can make an if statement out of a javascript statement that will change the html, that's all i need, an if statement that will change the html of the page

                Depending on what you need to do, sure, I've used JS to alter the HTML of pages.

                But now you start running into browser compatibility issues. The JS I originally made seemed to be compatible with IE only - not a good practice to code for.

                  would it work in firefox if the code was just changing an image's dimension?

                    Not sure. You'll have to give it a shot and see what happens.

                    Sorry I can't be of much help... my knowledge of JS is very limited. If I get time in the next few minutes, I can play around with FF and JS and see what I can come up with. If you're free right now though, you'll probably get results sooner by tinkering with it yourself.

                      nah, i g2g2 bed, almost 3am but i'm free all day tommorrow, or uh, today i guess :p

                      i'll give it ago but i won't really be able to know if works unless i can test it on a computer with a res smaller than 800x600

                      thx though

                        Since this has ended up being about Javascript, I'm moving it to a different forum.

                          'Morning weed!

                          I'm afraid that I'm going to have to give up on this one as well... sorry Samo. If you need help with the PHP side of it, feel free to re-post a PHP question! 😉

                            k, thx for...........saving hours of frustration :p

                            i'll let ya know if works

                              Write a Reply...