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

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Eiolon
Forum Newbie
Posts: 17
Joined: Tue Feb 14, 2006 1:42 pm

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

Post 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>
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

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

Post by kaszu »

When you display error, output also JS with "toggle();" call:

Code: Select all

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