Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

Clear Hash and ID

On a webpage, I have various divs with specific ID's (#contact, #newsletter, #thank-you,...)
However, in one of the divs there is a form, that on completion sends you to another div (#registration-thank-you)

So now, the url reads www.MYSITE.com#registration-thank-you.  How do I strip away the #registration-thank-you after the next click?
Avatar of Beverley Portlock
Beverley Portlock
Flag of United Kingdom of Great Britain and Northern Ireland image

What are you clicking on - a form button or a link? Also how did the URL get placed on that form/link?
Avatar of Robert Granlund

ASKER

@bportlock  Div ID via jQuery.ScrollTo
If the url is the action of the form just use javascript to change it on click:

document.getElementById('formid').action='www.MYSITE.com';

if the url is from a link same idea:

document.getElementById('linkid').href='www.MYSITE.com';


Cd&
Where do I place this on the form?
document.getElementById('formid').action='www.MYSITE.com';
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<form method="post" id="newsjoin">
                  <h4>Newsletter Signup</h4> :: <input name="email" type="text" id="email" class="newsletter-input" value="<?php if (isset($trimmed['email'])) echo $trimmed['email']; ?>" />
                  &nbsp;<div class="newsletter-button"><input name="submit" type="image" id="submit" src="../img/buttons/button-off.png" alt="Join Mailing List" /></div>
                              <input type="hidden" name="n_submitted" document.getElementById('newsjoin').action='dev.MYSITE.com'; value="TRUE" />
                              <input type="hidden" name="css" value="null" />
            </form>      


in the PHP there is this:
header('Location:#newsletter-thank-you');

So, the address looks like this: www.MYSITE.com#newsletter-thank-you

As soon as you navigate to a different ID on that page, I want the #newsletter-thank-you to go away.