SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2003
    Location
    Istanbul
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascrpt-php variable pass?

    Hello,
    I am new to java and I know a little php. I have a php page which I am trying to put into frames. And I have a problem about buttons...

    I am planning to have two vertically seperated frames, a thin one on the left, and the rest on the right. I ad buttons in the php page which, when clicked, refreshed the page and also loaded some new values to some variables so that the new page came out a little different. I know so far this sounds like a php stuff but my question is about javascript really
    When I tried to put this it frames, I wanted to have the buttons on the left frames and when clicked the left frame would pass the variable value to the right frame and refresh it. Shortly I figured out that this can be done by javascript. I found the following codes from a gentleman:

    left frame:

    <button onclick="parent.frames[1].foo='bar';parent.frames[1].document.getElementById('text').innerHTML='Current value of the <em>foo</em> variable: ' + parent.frames[1].foo;">Write "Hello, World!" to the other frame.</button>

    right frame:

    <script type="text/javascript">
    var foo="foo";
    onload = function() { document.getElementById('text').innerHTML = "Current value of the <em>foo</em> variable: " + foo; }
    </script>
    <div id="text"></div>

    This code successfully prints foo in right frame when button on left is pressed
    However what I really want to do is to load this "text" value into a php variable like $text. Then I can do anything with it, echo it, use it to modify some other value when the page is refreshed and so on. Is there any way to do this?

    Thanks in advance

    Have a nice day.

    Murat Isik

  2. #2
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a thought:

    If instead of writing the value to the innerHTML of a div, you wrote it to a hidden field of a form then providing your refreshed the page by submitting the form PHP could get the value.
    From the English nation to a US location.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •