Thread: quick question

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    56
    Rep Power
    15

    quick question


    Hello,
    I am new to javascript and I have a quick question:

    <button onclick="parent.tepe.foo='<?php echo $i?>';parent.tepe.document.getElementById('text').innerHTML='Current value of the <em>foo</em> variable: ' + parent.tepe.foo;">Write variable to the other frame.</button>

    I guess it is obvious what this does (took me some time to figure out)
    What I want to do is to transform this into script which gets "triggered" not when the button is pressed but only when the page is reloaded every time. Due to some other php function, the page will reload and $i will have changed so it would be great if this script automatically did its job.

    How can I do this?

    Thanks in advance.

    Have a nice day.

    Murat Isik
  2. #2
  3. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,004
    Rep Power
    2794
    <body onLoad=
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    56
    Rep Power
    15
    <body onLoad="parent.tepe.foo='<?php echo $i?>';parent.tepe.document.getElementById('text').innerHTML='Current value of the <em>foo</em> variable: ' + parent.tepe.foo;">

    I guess?
  6. #4
  7. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,004
    Rep Power
    2794
    Yup
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    56
    Rep Power
    15
    Thank you

    Have a nice day.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    56
    Rep Power
    15
    Well something else came up

    I tried to do it for two different variables:

    <body onLoad="parent.tepe.foo='<?php echo $aracson?>';parent.tepe.document.getElementById('text').innerHTML='Aracin bulundugu son nokta: ' + parent.tepe.foo;">
    <body onLoad="parent.tepe.zaman='<?php echo $date_end?>';parent.tepe.document.getElementById('text').innerHTML='Aracin bulundugu son nokta: ' + parent.tepe.zaman;">


    and

    <script type="text/javascript">
    var foo="";
    onload = function() { document.getElementById('text').innerHTML = "Point: " + foo; }
    </script>
    <div id="text"></div>
    <BR>
    <script type="text/javascript">
    var time="";
    onload = function() { document.getElementById('text').innerHTML = "Time: " + time; }
    </script>
    <div id="text"></div>


    Only Point: gets written and if I see it correctly first Time: is written then on it Point: is overwritten.

    Any ideas?
  12. #7
  13. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,004
    Rep Power
    2794
    Well yes, you are saying:

    Replace the value of TEXT with POINT + "FOO"
    Then replace TEXT with TIME + "TIME"

    Code:
    <html>
     <head>
      <script>
       function runOnLoad(){
        parent.tepe.foo = '<?php echo $aracson?>';
        parent.tepe.document.getElementById('text').innerHTML = 'Aracin bulundugu son nokta: ' + parent.tepe.foo;
        parent.tepe.zaman='<?php echo $date_end?>';
        parent.tepe.document.getElementById('text').innerHTML = 'Aracin bulundugu son nokta: ' + parent.tepe.zaman;}
      </script>
     <head>
     <body onLoad="runOnLoad();">
    
    
    
     </body>
    </html>
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    56
    Rep Power
    15
    Thank you

IMN logo majestic logo threadwatch logo seochat tools logo