Solved

onclick if statement for redirect

Posted on 2003-10-23
6
2,960 Views
Last Modified: 2007-12-19
i have a form that after you submit it will redirect to a certain page depending on department you are in.  There are only 5 departments that can access this site.  So i need to know how i can set up an IF statment to redirect the department to the correct location.  I orginally had it set up like this:


<% IF request.QueryString("department")<>"622"   then
               response.Redirect("faqs.asp")
          end if

     %>

then I tried a javascript redirect like this:

<script language=javascript>
function redirect() {
 if (department <> 661 or 664 or 659 or 212 or 311)
 {
window.location='faqs.asp';
      }
else
{
window.location='https://get.corerewards.com/coreinclude/_core_secure_access.asp';
}

</script>


So I'm not sure what I'm doing wrong. I have the onclick working when my java was:

<script language=javascript>
function redirect() {
 
window.location='faqs.asp';
      }


</script>

 I need an event that will go to the certain pages after they click the submit  button.  Can anybody help me?  It would be greatly appreciated!
0
Comment
Question by:diGeE
6 Comments
 
LVL 12

Expert Comment

by:kingsfan76
ID: 9611303
you are mixing VBscript syntax with jscript syntax

try:

if ((department != 661) &&  (department != 664) && (department != 659) && (department != 212) && (department != 311))
{
window.location='faqs.asp';
    }
else
{
window.location='https://get.corerewards.com/coreinclude/_core_secure_access.asp';
}
0
 
LVL 12

Accepted Solution

by:
kingsfan76 earned 50 total points
ID: 9611314
depend on what datatype department is, you might need to put the deparment number in quotes.
I suspect that department is a string, in that case, either put the number in quotes "661"
or parse department as int:

department = parseInt(department);
if (.......)
{
.......
}
0
 
LVL 30

Assisted Solution

by:third
third earned 50 total points
ID: 9611410

i suggest you use a server side script. and for security reasons, you also need to use "post" method rather than "get". querystring can be easily changed from the address bar and the user might be able to access any page. so i suggest,

<%
  dim department, location
  department = request("department")
   if department = "661" or department = "664" or department = "659" or department = "212" or department = "311" then
      location = "faqs.asp"
   else
     location = "https://get.corerewards.com/coreinclude/_core_secure_access.asp"
   end if
   response.redirect(location)
%>

another drawback of using client side script is, it can be disabled by the user.
0
 
LVL 23

Assisted Solution

by:adilkhan
adilkhan earned 50 total points
ID: 9611866
>  if (department <> 661 or 664 or 659 or 212 or 311)

Should be

 if (department != 661 || department!=664 || department!=659 || department!=212 || department!=311)

in javaScript

<> = !=
OR = ||
AND = &&
what is department is equall to?
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10345912
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: kingsfan76 {http:#9611314} & third {http:#9611410} & adilkhan {http:#9611866}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now