NEED help to pass javascript variable to php

Discussion in 'Programming' started by psyphil, May 8, 2008.

  1. #1
    I'm trying to pass a javscript variable to php to be used as a php variable.

    Code looks like

    <script>
    screen_width=screen.width //I want to use this screen_width in php
    </screen>

    <?php
    $screen_width= ;//I want screen_width to be assigned to this
    ?>

    1# I dont want to pass the variable through form and $_get since it loads the page again and takes visitor to a new page. Is there any way that it could be done with $_post without redirecting but with reloading ( more suitably autoreloading .)

    2# Is there a way I can assign js var to php variable with ajax,iframes ..

    Any help will be appreciated.Thanks
     
    psyphil, May 8, 2008 IP
  2. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #2
    You can use java server page , write some cookie and probably read it using php.
     
    it career, May 9, 2008 IP