how do I call two links in one click?

Discussion in 'PHP' started by ji394su30935, Jun 16, 2010.

  1. #1
    my website has 2 frames that have to change all the time(main content, and news), so sometimes when I click on one link(from navigation), I want it to call two links for me(one of them changes main content, and one of them changes news).

    for exampe, how to I call two links from below in one click?
    <a href="index.php?news=hi">Hi</a>
    <a href="index.php?news=hello">Hello</a>

    I tried something like this but it doesn't work :
    <a href="index.php?news=hi" AND "index.php?news=hello">Hi and Hello</a>

    I also notice there is a way to use "Onclick" function to solve the similar problem, but it does not fit in my code.

    Please, help me if u know the answer.
    thank you
     
    ji394su30935, Jun 16, 2010 IP
  2. netload

    netload Member

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #2
    Bad solution

    Try <a href="index.php?news=hi" onclick="window.open('index.php?news=hello')">Hi and hello</a>

    P.S. Some browsers and security plugins block window.open method.


    P.S.S. Another solution - create hdden form with target=_blank

    <form id='my_hidden_form' method='get' action='index.php?news=hello' target=_blank>
    </form>

    and do onclick="document.getElementById('my_hidden_form').submit()"

    getElementById doesn't work in some browsers
     
    netload, Jun 17, 2010 IP
  3. ji394su30935

    ji394su30935 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I am sorry that i did not make my question clear.

    I am not opening any new page. Two links below are just opening two different sections in a page.
    <a href="index.php?content=hi">Hi</a>
    <a href="index.php?news=hello">Hello</a>

    again, how would I do that?

    thanks for replying
     
    ji394su30935, Jun 17, 2010 IP
  4. netload

    netload Member

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #4
    If you use <frame> you can try attribute target='your_frame_name' in <a> and <form>
     
    netload, Jun 17, 2010 IP
  5. ji394su30935

    ji394su30935 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    what if my frame is divided using tables? not <frame>
    does that mean i have to rebuild my web page?
     
    ji394su30935, Jun 17, 2010 IP
  6. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #6
    Just add a second parameter to the link. link=1&amp;link2=3

    Simples.
     
    HuggyEssex, Jun 17, 2010 IP
  7. netload

    netload Member

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #7
    Maybe jQuery (JavaScript framework) can help you. After click you should send 2 AJAX requests and after that rebuild your web page (via jQuery, without reload).
     
    netload, Jun 17, 2010 IP
  8. ji394su30935

    ji394su30935 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    i wish it works but it doesn't
    <a href="index.php?content=a";"index.php?news=b">click</a>
     
    ji394su30935, Jun 17, 2010 IP
  9. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #9
    You need to add into the PHP so it can take the second parameter, HTML will not get this done. As I said just add a second parameter to the link.
     
    HuggyEssex, Jun 17, 2010 IP
  10. ji394su30935

    ji394su30935 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    can you give me a more specific example about how to add a second parameter?
    I searched everywhere and still can't find a solution.

    it is still reading the first link; not the second link
    this is my code:
    <?php
    echo"<a href='index.php?content=a';'index.php?news=b'>click</a>";
    ?>
     
    ji394su30935, Jun 17, 2010 IP
  11. amaroks

    amaroks Peon

    Messages:
    242
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    This shouldn't make it?
     
    amaroks, Jun 18, 2010 IP
  12. ji394su30935

    ji394su30935 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    amaroks, this code will trigger another screen to open, and i don't want that.
    two links of mine should open two sections in my window.
     
    ji394su30935, Jun 18, 2010 IP
  13. ked38

    ked38 Peon

    Messages:
    232
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Two simpler methods:

    1. use javascript.

    or

    2. if using frameset, eg top frame & menu frame
    then change two html pages (page1.html & banner.html) at same time with one user click.
    Note the frames[] container.

    <li><a href="http://www.yoursite.com/page1.html" onclick="top.frames[1].location.href='banner.html'" target="mainFrame">page1</a></li>



    Best regards,
    Ked38
     
    ked38, Jun 18, 2010 IP