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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect problem 1

Status
Not open for further replies.

cumap

IS-IT--Management
Jul 9, 2007
268
US
Hi all,

I copied this code to direct me to a particular page, but it doesn't seem to work at all, could someone point it out to me why is it so?

Code:
document.forms[0].action = "update.asp";
document.forms[0].submit();
thanks
 
yes I do have the form to submit and on a update button, I includes OnClick="update();", and this is the whole js code for the update button.
Code:
function Update()
{
	if (confirm("This will update the changes! Are you sure you want to do this?"))
	{
		document.forms[0].action = "update.asp";
		document.forms[0].submit();
	}
}

and, what is meant "doesn't seem to work at all" because I know for sure the code has never brought me to that update.asp at all. To know so, I have HTML text to confirm and so far, nothing happens and all I got is back to the current page I am in.
 
by the way, I know the code is activated because the confirm message was displayed before taking me straight back to where I am instead of going to the other page as specified.
 
I'm sorry... the unconsistent error was happen while typing for the message here only, I DO have both the OnClick and Function name match perfectly. So, it is not a case.
 
I give up, I don't see the rest of the ASP code has anything to do with this JS function. I decide not to utilize this confirm function but to go-ahead to process the form anyway.

Thank you for your help anyway, Feherke!
 
I realized the problem is that forms[0] does not automatically understand my form name, so to fix the problem, I assigned the form name to it and it works now. It is partly my fault for not understanding the code very well, but I also blame it on the online tutorial that assumed whoever learning from its technique is already supposed to know that issue.

Thanks all.

 
Hi

cumap said:
I realized the problem is that forms[0] does not automatically understand my form name, so to fix the problem, I assigned the form name to it and it works now
Sorry, but the best I can say is "WTF" ?

The below works in Mozillas, Opera, Safari and Explorer. What could ASP generate so wrong in that so the JavaScript fails ?
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title></title>
<script type="text/javascript">
function Update()
{
    if (confirm("This will update the changes! Are you sure you want to do this?"))
    {
        document.forms[0].action = "update.asp";
        document.forms[0].submit();
    }
}
</script>
</head>
<body>
<form action="#">
<p>
<input type="button" onclick="Update()">
</p>
</form>
</body>
</html>

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top