Navigation menu issue after page reload
The trouble is that I have a contact form on the page. When a user clicks the contact button in the menu, the page slides over to the contact form section and the contact button becomes "active". After filling out the form and pressing submit, the page gets reloaded and I have some PHP handling the validation and mailing. In the form action i have it return to the contact portion of the page (action = "index.php#contact), where it displays errors or a success message. But even though the user is viewing the contact form, since the page has been reloaded, the default "home" button turns on, instead of the contact button.
I need to find a way so that once the page is reloaded by either a succesful or unsucessful contact form submission, to keep the contact button "on", instead of reverting to the default "home" button being turned on.
I thought I could use a PHP variable, with a default value and then a new value would be given to it after the submit button was pressed. By checking the value of that variable, I could see if the page was being loaded the first time (and to therefore turn the home button on) or if it was being reloaded after submitting the form (and therefore turn the contact button on). However, this approach did not work. I also tried using document.getElementById().value to get the value of a hidden form field. However, I didn't realize that the value exists even before the user has pressed the submit button. Since the value always stayed the same, the conditional statement was always true, so that didn't work either
Setting a button to the active state (on until another is clicked) is just a simple function call, so to turn the home button to the "on" state button I just call a function "mActive(img2,2)" in a window.onload function I have for some other stuff. The contact form is just a plain HTML form, nothing special.
Does anyone know how I cout get this to work? Your help would be greatly appreciated. I wasted half a day trying to figure this out! Thanks in advance.
P.S. Sorry that was really long, I hope I explained everything clearly!