SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2007
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to go to anchor link (for example the bottom page), after clicking submit button?

    Using below script after clicking the button it will reload the page and starting the application

    I want people go to anchor link location after clicking the submit button, for example go to the bottom of the page because the program is in the bottom of the page

    how to do that guys please help




    Code:
    echo '<form action="" id="frm_chat" method="post"><fieldset id="fieldset_chat"><legend>Chat</legend><div>';
    	echo $err_msg;
    	echo "<label>Nick: </label>".$txt_nick->getHtml()."<br />";
    	echo "<label>Server: </label>".$ddl_server->getHtml()." or ".$txt_server->getHtml()."<br />";
    	echo "<label>Channel: </label>".$ddl_channel->getHtml()." or ".$txt_channel->getHtml()."<br />";	
    	
    	echo ' <input type="submit" class="btn" name="btn_chat" value="Chat Now"/></div></fieldset></form>';
    Make the world better

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Don't know if this would work for the same page, but you could try putting an id on the header for the section--e.g

    <h2 id="anchor">Anchor</h2>

    and them make the return url that section of the page:

    header ('Location: #anchor');

    or maybe

    header ('Location: index.php#anchor');

    but I've not tried it. It would be easy if you were landing on another page.

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by ralph.m View Post
    It would be easy if you were landing on another page.
    The same code will work regardless of whether it is the same page or a different page being loaded if you include the filename of the page before the #.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    header ('Location: #anchor');

    or maybe

    header ('Location: index.php#anchor');
    Both would be invalid, since the Location header requires an absolute URI (see RFC2396 for a definition).

    Most browsers probably work with a relative URI as well, but you'd be relying on non-standard behaviour.
    Birnam wood is come to Dunsinane

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,299
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    Both would be invalid, since the Location header requires an absolute URI
    Eek! Cheese and rice, it's amazing how unreliable books can be. How are we noobs to survive?

    Answer: by the helpful advice of Tommy and co. Thanks for pointing this out.


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
  •