Jump to content

Recommended Posts

hi all.

 

my issue is that im using php pages for my code and i cant get an anchor to work.

 

im trying to get it to load the page half way down directly from a submit button.

 

the section i want to be seen ive called CM so above that section i have <A NAME="CM"></A>

 

and for my submit button i have added ???.php#CM to the URL but it loads like normal showing top of page.

 

any help welcome.

Link to comment
https://forums.phpfreaks.com/topic/250297-anchor-name-tag-issues-please-help/
Share on other sites

main page code is here blah blah

<a name="cm"></a>

this section i want to show

....................................................................................

<form method="post" action="mypage.php?page=myview#cm">
<input name="test" type="text" id="test" size="80" value="" /></form>

Submit buttons are used for submitting forms, they are not links. The reason you are having troubles is because you are trying to force the button to do something it doesn't do. Use an <a> tag if you want to link to somewhere else on the page.

 

fair enough , so are you saying its impossible to submit a form and to load the same page (after submitting) in a specific location (like a link would) ???

My apologies, I didn't realize you wanted it to move to the hash after submitting the form. I thought you wanted to have it happen on the same page.

 

Try just using the hash only as the action:

 

<form action="#cm">

 

If that doesn't work, you could use a php header() call in your form processing, and redirect to the same page with the hashmark. This will give the added bonus of being able to reload the page without re-submitting the form values. Unfortunately, it will mean you can't use any data generated in your processing script in the same page - you will have to store it somewhere between the redirect.

hmmmm ........... the page it self shows details at top of page , then half way down the user can comment , but when they submit there comment it loads the same page but from the top , ide like it to show there comments as soon as they post it (which is half way down that page) ......

 

this is the page ... notice the comments section is under the main part .....

 

php1.jpg

 

when the enter there comment i want the page to load where the comments are like this ............

 

php2.jpg

 

NOT like the 1st pic showing the top half also.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.