SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: multipage url

  1. #1
    eigo hanasemasu ka? Yes. =) ZuulJin's Avatar
    Join Date
    Dec 2001
    Location
    Japan
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multipage url

    The code I have so far looks like this:
    Code:
    <a href="index.php?cat=$row[name]" onClick="java script: content.location.href = 'disp_cat.php?cat=$row[name]'">$row[name]</a>
    Is this possible? As you can see, I am trying to send a variable to index.php (main Page) and disp_cat.php (iframe) in one click. $row[name] gets it's value from a database.

    My problem is with the javascript. What do I need to do in order to pass a variable to an iframe with Javascript? What I have written above doesn't work.

    (I'm new to Javascript, I am a PHP programmer)

    Thanks for any help!
    U.S. DoD Member in Japan?
    Choose your base. Buy|Sell. Easy
    @ APO Ads.



  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hope you mean that your code looks like this:
    <?
    echo "<a href=\"index.php?cat=$row[name]\" onClick=\"java script: content.location.href = 'disp_cat.php?cat=$row[name]'\">$row[name]</a>";
    ?>

    If you are really quick, you can see the location change in the iframe, before index.php is loaded into the window
    (Change onClick to onMouseDown if you want to be able to see the change for a longer time)

  3. #3
    eigo hanasemasu ka? Yes. =) ZuulJin's Avatar
    Join Date
    Dec 2001
    Location
    Japan
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh damn... I didn't even notice that it WAS loading the page in the url correctly... just that the index.php loading was reloading the iframe as well... crap.

    yeah, my code did look like that, I was just more worried about the javascript.

    Thanks for the help.
    U.S. DoD Member in Japan?
    Choose your base. Buy|Sell. Easy
    @ APO Ads.



  4. #4
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think if you want to stop it loading the page in the URL you need to add "return false" to the onClick event. The problem is that doing that will stop the page in the URL from being loaded at all, so your variable will not be passed to that PHP script.

    If you have control over the PHP scripts you should have no problems loading a single script with the variable which in turn loads the other two scripts with that variable - you should definitely change the architecture of your PHP application (if it's having to rely on weird javascript hacks to transmit information to two scripts at once then something is definitely wrong).

  5. #5
    eigo hanasemasu ka? Yes. =) ZuulJin's Avatar
    Join Date
    Dec 2001
    Location
    Japan
    Posts
    655
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a process of learning... I just wanted to know if it was possible.

    Thanks for the help.
    U.S. DoD Member in Japan?
    Choose your base. Buy|Sell. Easy
    @ APO Ads.




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
  •