onclick if statement for redirect

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!
diGeEAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kingsfan76Commented:
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
kingsfan76Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
thirdCommented:

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
Saqib KhanSenior DeveloperCommented:
>  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
jaysolomonCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.