Solved

onclick if statement for redirect

Posted on 2003-10-23
6
2,958 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

757 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

22 Experts available now in Live!

Get 1:1 Help Now