PDA

View Full Version : Page Redirect+Alert Message


rhpriya
08-01-2005, 01:58 PM
Hi,
I need to check for the user loginname and alert an error if I dont find a username.
the following code alerts proper messages, but after I click on OK the page still gets redirected instaed of staying in the same page.

I want to stay on the login page until there is some value in the "user" variable.
Can anybody help me to point out what I am doing wrong here?

<script language="JavaScript1.2" type="text/JavaScript1.2" >
function askLogin()
{
var user = "<%=Session("MM_Username")%>";
if( user == "")
{
alert("Please login to add a new request or view requests list");
return;
}
}
</script>

</head>

<body>

<p class="linkText">&nbsp;</p>
<p class="linkText">&nbsp;</p>
<p class="linkText"><a href="login.asp" target="indmainFrame">Login</a></p>
<p class="linkText"><a href="redirectNewOrList.asp?calledFrom=new" onClick="askLogin();" target="indmainFrame">New request</a></p>
<p class="linkText"><a href="requestlists.asp" target="indmainFrame" onClick="askLogin();">Requests list</a></p>
<p class="linkText style1">Reports</p>
<p><span class="linkText style1">Search</span> </p>
</body>
</html>

Thanks
RHP

RysChwith
08-01-2005, 04:17 PM
Change "return;" to "return false;" in the askLogin() function. Also, change this: "<script language="JavaScript1.2" type="text/JavaScript1.2" >" to this: "<script type="text/javascript" >".

Rys

rhpriya
08-02-2005, 02:12 PM
Hi,
thanks for the response. It did not work though. I am not sure how to stop a redirect from the link HREF.

Please help.
Thanks