Solved

onclick if statement for redirect

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

789 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