Solved

onclick if statement for redirect

Posted on 2003-10-23
6
2,961 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:Saqib Khan
Saqib Khan 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

810 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