INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Redirect script if specific id and database field then redirect

Redirect script if specific id and database field then redirect

Redirect script if specific id and database field then redirect

(OP)
Hello,

I am by no means a programmer, but I was able to build a small JavaScript that redirects users to a link depending on their name. this works well.

I need to add a condition to my script but not sure how to go about it.

This is what my script looks like

CODE --> JavaScript

<script language="JavaScript">

temp= window.prompt ("Please Type Your Name" , "");
if (temp=="") { window.location="http://mywebsite/rma1/redirect.asp?id=<% = Cdbl((rsGuestbook("ID")))%>";}


else if (temp=="Shu"|| temp=="shu"|| temp=="SHU"|| temp=="SShah" || temp=="Justin"|| temp=="JUSTIN"|| temp=="justin"|| temp=="JThomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME" || temp=="piotr" ||temp=="PIOTR")  { window.location="http://mywebsite/rma1/editquality.asp?id=<% = Cdbl((rsGuestbook("ID")))%>&" + "temp=" + temp;}

else if (temp=="Kim"|| temp=="kim"|| temp=="mike"|| temp=="Mike"|| temp=="MIKE"|| temp=="barb"|| temp=="Kimberligh")  { window.location="http://mywebsite/rma1/editcredit.asp?id=<% = Cdbl((rsGuestbook("ID")))%>&" + "temp=" + temp;}

else if (temp=="George"|| temp=="george"|| temp=="veronica"|| temp=="Veronica"|| temp=="VERONICA"|| temp=="Cindy"|| temp=="GEORGE"|| temp=="JESS"|| temp=="jessica"|| temp=="Jessica"|| temp=="jess"|| temp=="Jess"|| temp=="Kevin"|| temp=="kevin"|| temp=="Shu"|| temp=="shu"|| temp=="Sue"|| temp=="tina"|| temp=="Tina"|| temp=="TINA"|| temp=="sue"|| temp=="Justin"|| temp=="JUSTIN" || temp=="JTomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME" || temp=="Piotr" || temp=="piotr" ||temp=="PIOTR" || temp=="cynthia" || temp=="CYNTHIA" ||temp=="Cynthia")  { window.location="http://mywebsite/rma1/editcustserv.asp?id=<% = Cdbl((rsGuestbook("ID")))%>&" + "temp=" + temp;}
</script> 

so what I am looking to do is

CODE

else if (temp=="Shu"|| temp=="shu"|| temp=="SHU"|| temp=="SShah" || temp=="Justin"|| temp=="JUSTIN"|| temp=="justin"|| temp=="JThomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME" || temp=="piotr" ||temp=="PIOTR") and database field frmtype = credit then redirect to { window.location="http://mywebsite/rma1/editquality.asp?id=<% = Cdbl((rsGuestbook("ID")))%>&" + "temp=" + temp;} 

Not sure how to add the highlighted part

I think I could do a variable?

CODE

var S=document.form.frmtype.value; 
and insert it where the highlighted code is ??

any suggestions are more than welcome!!


Thanks


EV

RE: Redirect script if specific id and database field then redirect

How is that database field getting to the page?

Are you storing it in a form field?

If so, then yes, you can get it into a variable as you show and add that requirement to your conditional statement.

If not then it would depends on how that value is coming in.



----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech

RE: Redirect script if specific id and database field then redirect

(OP)
vacunita,

Yes it is being stored in a form field.

the part that I am a bit confused is how to actually I implement it

would it be something like this?

CODE

var S=document.form.frmtype.value; 

else if ((temp=="Shu"|| temp=="shu"|| temp=="SHU"|| temp=="SShah" || temp=="Justin"|| temp=="JUSTIN"|| temp=="justin"|| temp=="JThomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME" || temp=="piotr" ||temp=="PIOTR") and S="credit") { window.location="http://webdav/rma1/editquality.asp?id=<% = Cdbl((rsGuestbook("ID")))%>&" + "temp=" + temp;} 

RE: Redirect script if specific id and database field then redirect

The comparison should be with && not "and" just like your previous comparisons use || not "or". and you need double equal signs for the comparison. ==


So:

CODE

else if ((temp=="Shu"|| temp=="shu"|| temp=="SHU"|| temp=="SShah" || temp=="Justin"|| temp=="JUSTIN"|| temp=="justin"|| temp=="JThomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME" || temp=="piotr" ||temp=="PIOTR") && S=="credit") {...} 

----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech

RE: Redirect script if specific id and database field then redirect

(OP)
vacunita,

makes sense, I understand it.

I appreciate it thank you!!!!

RE: Redirect script if specific id and database field then redirect

(OP)
vacunita,

I tried that but not much luck,

the part of the script that asks for the user name does not show up, it goes straight to the deny page, because there is no user name

this is the begginging of the script

CODE --> JavaScript

temp= window.prompt ("Please Type Your Name" , "");
if (temp=="") { window.location="http://mywebsite/rma1/redirect.asp?id=<% = Cdbl((rsGuestbook("ID")))%>";} 

no idea why

RE: Redirect script if specific id and database field then redirect

Not quite sure I understand, Your condition there checks to see if temp is an empty string =="" . If it is an empty string, it will redirect to http://mywebsite/rma1/redirect.asp?id=<;% = Cdbl((rsGuestbook("ID")))%>
Otherwise it will continue on.

What exactly is not working?

How are you calling this?

----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech

RE: Redirect script if specific id and database field then redirect

(OP)
so I have the script (scroll right to see the other highlighted code)

CODE

<script language="JavaScript">



temp= window.prompt ("Please Type Your Name" , "");
if (temp=="") { window.location="http://webdav/rma1/redirect.asp?id=<% = Cdbl((rsGuestbook("ID")))%>";}


else if (temp=="Shu"|| temp=="shu"|| temp=="SHU"|| temp=="SShah" || temp=="Justin"|| temp=="JUSTIN"|| temp=="justin"|| temp=="JThomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME" || temp=="piotr" ||temp=="PIOTR" ||temp=="Piotr")  { window.location="http://webdav/rma1/editqualityreturns.asp?id=<% = Cdbl((rsGuestbook("ID")))%>&" + "temp=" + temp;}

else if (temp=="Kim"|| temp=="kim"|| temp=="mike"|| temp=="Mike"|| temp=="MIKE"|| temp=="barb"|| temp=="Kimberligh")  { window.location="http://webdav/rma1/editcredit.asp?id=<% = Cdbl((rsGuestbook("ID")))%>&" + "temp=" + temp;}

else if (temp=="George"|| temp=="george"|| temp=="veronica"|| temp=="Veronica"|| temp=="VERONICA"|| temp=="Cindy"|| temp=="GEORGE"|| temp=="JESS"|| temp=="jessica"|| temp=="Jessica"|| temp=="jess"|| temp=="Jess"|| temp=="Kevin"|| temp=="kevin"|| temp=="Shu"|| temp=="shu"|| temp=="Sue"|| temp=="tina"|| temp=="Tina"|| temp=="TINA"|| temp=="sue"|| temp=="Justin"|| temp=="JUSTIN" || temp=="JTomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME"  || temp=="cynthia" || temp=="CYNTHIA" ||temp=="Cynthia") && (rmat=="Credit") { window.location="http://webdav/rma1/editcustservreturnscredit.asp?id=<% = Cdbl((rsGuestbook("ID")))%>&" + "temp=" + temp;}

else if ((temp=="George"|| temp=="george"|| temp=="veronica"|| temp=="Veronica"|| temp=="VERONICA"|| temp=="Cindy"|| temp=="GEORGE"|| temp=="JESS"|| temp=="jessica"|| temp=="Jessica"|| temp=="jess"|| temp=="Jess"|| temp=="Kevin"|| temp=="kevin"|| temp=="Shu"|| temp=="shu"|| temp=="Sue"|| temp=="tina"|| temp=="Tina"|| temp=="TINA"|| temp=="sue"|| temp=="Justin"|| temp=="JUSTIN" || temp=="JTomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME"  || temp=="cynthia" || temp=="CYNTHIA" ||temp=="Cynthia")) && (rmat=="Return") { window.location="http://webdav/rma1/editcustservreturns.asp?id=<% = Cdbl((rsGuestbook("ID")))%>&" + "temp=" + temp;}

</script>
<script>
function initialize()
{
 document.forms['form'].elements['csupdatedby'].value = temp ;
  document.forms['form'].elements['rmatype'].value = rmat ;
}
</script> 
I added the hightlighted code but by adding that it bypasses the

CODE

temp= window.prompt ("Please Type Your Name" , ""); 
and goes directly to

CODE

if (temp=="") { window.location="http://webdav/rma1/redirect.asp?id=<% = Cdbl((rsGuestbook("ID")))%>";} 

RE: Redirect script if specific id and database field then redirect

The problem is with your conditionals. All Conditions should be surrounded by () for the entire condition. You are putting parts of your conditions outside the () of each else if statement.

This causes the JS to error out, and simply not run, which means your page simply loads as is.


Try:

CODE

else if ((temp=="George"|| temp=="george"|| temp=="veronica"|| temp=="Veronica"|| temp=="VERONICA"|| temp=="Cindy"|| temp=="GEORGE"|| temp=="JESS"|| temp=="jessica"|| temp=="Jessica"|| temp=="jess"|| temp=="Jess"|| temp=="Kevin"|| temp=="kevin"|| temp=="Shu"|| temp=="shu"|| temp=="Sue"|| temp=="tina"|| temp=="Tina"|| temp=="TINA"|| temp=="sue"|| temp=="Justin"|| temp=="JUSTIN" || temp=="JTomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME"  || temp=="cynthia" || temp=="CYNTHIA" ||temp=="Cynthia") && (rmat=="Credit")) 


and

CODE

else if ((temp=="George"|| temp=="george"|| temp=="veronica"|| temp=="Veronica"|| temp=="VERONICA"|| temp=="Cindy"|| temp=="GEORGE"|| temp=="JESS"|| temp=="jessica"|| temp=="Jessica"|| temp=="jess"|| temp=="Jess"|| temp=="Kevin"|| temp=="kevin"|| temp=="Shu"|| temp=="shu"|| temp=="Sue"|| temp=="tina"|| temp=="Tina"|| temp=="TINA"|| temp=="sue"|| temp=="Justin"|| temp=="JUSTIN" || temp=="JTomas" || temp=="Jaime" || temp=="jaime" ||temp=="JAIME"  || temp=="cynthia" || temp=="CYNTHIA" ||temp=="Cynthia") && (rmat=="Return")) 

When using Js use your Browser's JS Console to check for JS errors. Its important to keep an eye on the console closely as you code.

----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close