Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if statement help 1

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
hello,
I have a an asp page that shows a view of a record, if you click on edit then the script below is activated, the script lives in the edit page
Code:
<script language="JavaScript">
temp= window.prompt ("Please Type Your Name" , "");
if (temp=="")  { window.location="[URL unfurl="true"]http://mywebsite.com/myblankpage.html";}[/URL]
</script>


right now in the example above, if the temp is blank then it takes you to a page asking you to enter a name, if the temp is not blank then it sends you to edit the record

what I am trying to do is to add users and be able to redirect them to a specific record
Code:
if (temp=="Joe", "Sam", "sam", "joe")  
{ window.location="[URL unfurl="true"]http://mywebsite.com/editpage.asp?id=23";}[/URL]

not sure if this is possible

thanks!!!
 
You can either use the || (or) operator, or use a switch statement.

Code:
if(temp=="Joe" [red]||[/red] temp=="Sam" || temp=="sam"){
do something...
}

Switch statement:

Code:
switch(temp){
case "Joe":
do something....
break;
case "Sam":
do something else
break;
...
}

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
thanks vacunita,

got it.

for the re-direction?

on my asp page I have a Dim IngRecordNo right before my sql statement

could I do something like this
var S=document.form1.company.value;
Code:
 var A=document.IngRecordNo.value;

if (temp=="Joe", "Sam", "sam", "joe")  
{ window.location="[URL unfurl="true"]http://mywebsite.com/editpage.asp?id='[/URL] + escape(A);}
 
Not to familiar with ASP, but that looks correct assuming the variable A contains the proper value you want to pass to your other page.
Its theoretically sound.
Though you may want to form your URL outside the window.location call and then just pass it as variable to it.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
sorry not sure exactly how to acomplish that, I am not very savy in javascript
 
Given you are savvy with ASP, however, why not simply present a form input and do all the processing and redirecting server-side?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Code:
var myurl="[URL unfurl="true"]http://mywebsite.com/editpage.asp?id="[/URL] + escape(A);
window.location=myurl;

Of course Dan makes an excellent point. Its always better to do the processing server-side.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
vacunita.... your rule!!!! I really appreciate all your help Thank you!!!!!!!
 
You're welcome.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top