SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing url data to two scripts simultaniously?

    I have a list of links that when clicked open a script in another frame based on url info. I need to have the same info sent to another script in another frame whan the the link is clicked. Is there anyway to do this with Javascript using onclick or onload? Sorry but I can do php but I know nothing about Javascript.

    Example link.

    PHP Code:
     
     <a
      href="makes_tree_test.php?item=<?php echo $name_item?>"
      target="makes"><font
      size="2"><?php echo $name_item?></font></a>

  2. #2
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess this forum isn't that active.

    Anyway, I found out how to do it.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Play around with this and you should be able to get what you want:
    Code:
    function test(url1, url2) {
      document.frames['frame1'].src = url1;
      document.frames['frame2'].src = url2;
    }
    Code:
    <a href=# onClick="test('./script1.php?item=<?php echo $var;?>', './script2.php?item=<?php echo $var;?>');">
      link
    </a>

    www.unpossiblemedia.com - A Fort Lauderdale based multimedia company.

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Wouldn't it need to be
    Code:
    <a href="javascript:test('./script1.php?item=<?php echo $var;?>', './script2.php?item=<?php echo $var;?>');">
      link
    </a>

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, or what I changed it too. Tired.

    www.unpossiblemedia.com - A Fort Lauderdale based multimedia company.

  6. #6
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Lol.. OK

  7. #7
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did it like this.

    PHP Code:
    <head>
    <
    SCRIPT LANGUAGE="JavaScript">
    <!-- 
    Begin
    function loadFrames(frame1,page1,frame2,page2,frame3,page3) {
    eval(
    "parent."+frame1+".location='"+page1+"'" );
    eval(
    "parent."+frame2+".location='"+page2+"'" );
    eval(
    "parent."+frame3+".location='"+page3+"'" );
    }
    // End -->
    </script>
    <title> 
    PHP Code:
    <a href="java script:loadFrames('makes', 'makes_tree_test.php?item=<?php echo $name_item?>', 'stuff.stuff1', 'stuff.php?item=<?php echo $name_item?>', 'stuff.stuff2', 'stuff2.php')"><font
    size="2"><?php echo $name_item?></font></a>

  8. #8
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, and it works great.

  9. #9
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd like to point out that you should be setting the location.href property, not the location itself - although some browsers will accept this (because they make allowances for sloppy code), it's not technically correct, and hence some browsers may throw an error.
    Code:
    function loadFrames(frame1,page1,frame2,page2,frame3,page3) {
    eval("parent."+frame1+".location.href='"+page1+"'" );
    eval("parent."+frame2+".location.href='"+page2+"'" );
    eval("parent."+frame3+".location.href='"+page3+"'" );
    }
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  10. #10
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I'll give it a try. The code I found did say 2000 as the date so it's a bit old.

  11. #11
    Now with customized title Jump's Avatar
    Join Date
    Sep 2002
    Location
    The Restaurant at The End of The Universe
    Posts
    1,423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still works great. thanks for the tip. I don't want sloppy code.

  12. #12
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


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
  •