Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with reset value when use history.go(-1)

Status
Not open for further replies.

cat5ive

MIS
Joined
Dec 3, 2004
Messages
184
Location
US
Hi,

I have 2 asp pages. When I click submit in page1, it go to page2. Page2 validate a value (invoice#) that was input in page1. If it's not a good invoice#, then I redirect back to page1 (with the error flag and invoice# append to url).
Code:
newurl = "page1.asp?errflag=1&invnumber=" + strinvnumber
Response.redirect newurl
In the beginning of page1, I check the error flag. If found I pop up the alert box.
Code:
 <script type="text/javascript" defer>
  <!--
    	
	strflag = "<%=Request.Querystring("errflag")%>";
	strinvnumber = "<%=Request.Querystring("invnumber")%>";
	 	 
	if (strflag != "")
	{  
	    errflag = "";
	    errmsg = "Invoice# " + strinvnumber + " already exist but not miscelleous invoice. Change not allowed";
	    alert (errmsg);
	}
Problem is here. After I get alert box, I changed the invoice# to a good number and click submit to go to page2. If I click cancel from page 2 to go back to page1, the alert box will pop up. So it seem like when I go back to page1, the error flag that I pass ealier still there. How do I reset it.
This is code for my cancel botton.
Code:
<td align="right"><a href="javascript:history.go(-1)"><img src="images/cancel.gif" border="0"></a></td>

Thanks
 
Hi Dan,

The reason I use history.back is because if I click back button on page1 it will take me to the page before page1 (menu page). But if I use redirect URL in the cancel button, when I click back button in page1 it will take me back to page2.

Code:
// with history.back

menu---------->page1-------->page2
     <--------        <-------
       back             cancel  

// with URL

menu---------->page1-------->page2
                    <-------
                      cancel  
                     ------->  
                       back
 
continue reply.

Even I change to URL, I will have same problem when I click back button on page2 as I do click cancel button.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top