Page 1 of 1

Show/Hide div - not keeping div shown if error occurs

Posted: Mon Jul 12, 2010 9:18 am
by Eiolon
I am using javascript that will show/hide a DIV if a link is clicked. In the DIV is a form.

When the user input's form info, and the form is processed, if there is an error the page reloads displaying the error. However, the user must click the link again to see the form and correct their mistake. Is there a way to keep the div shown on reload?

Thanks!

Code: Select all

<script language="javascript"> 
function toggle() {
	var ele = document.getElementById("show");
	var text = document.getElementById("add");
	if(ele.style.display == "block") {
    		ele.style.display = "none";
		text.innerHTML = "show";
  	}
	else {
		ele.style.display = "block";
		text.innerHTML = "Add Participant";
	}
} 
</script>

Re: Show/Hide div - not keeping div shown if error occurs

Posted: Mon Jul 12, 2010 2:01 pm
by kaszu
When you display error, output also JS with "toggle();" call:

Code: Select all

<script type="text/javascript">
toggle();
</script>