/    Sign up×
Community /Pin to ProfileBookmark

if statements

I’ve been trying and can’t seem to get this to work. I have just added a new page so I just started needing to do this. I have several different ‘scales’ for my rating systems. I want:

if sScale = a then
go to pageA.asp
else
go to pageB.asp.

I’m not able to get this to work with the info in the list (i’d like to keep it in a list. Here’s my previous list if it could be of any help.
Thanks in advance

<ul>
<li><a href=”/Member/FSR/FSR_Scoresheet.asp?iAsmtID=<% = iAsmtID%”>Enter/Modify scores</a>&nbsp;on web-based scoresheet</li>
</ul>

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Dec 11.2007 — Bad idea to do this with Javascript really. Use a server side language like ASP or PHP as you can be sure it exists.
Copy linkTweet thisAlerts:
@nap0leonDec 11.2007 — I presume this code is going into the top of FSR_Scoresheet.asp to redirect the user to the page based on a value in the URL?

If you want to send a user to a specific page using JavaScript, this would work:
[CODE]
if (sScale = a) {
self.location.href = 'pageA.asp';}
else {
self.location.href = 'pageB.asp';}
[/CODE]


It's been awhile since I've played with these... you might need to make the paths fully qualified (http:// ...)

Also could try window.location.href or window.location.pathname - they all work slightly differently.
Copy linkTweet thisAlerts:
@KorDec 11.2007 — What is [B]sScale[/B] ? What is [B]a[/B]?

[B]nap0leon[/B] , the comparison operators are [COLOR="Red"]==[/COLOR] (value) and [COLOR="Red"]===[/COLOR] (value and type). [COLOR="Blue"]=[/COLOR] is only an [I]assignment[/I] operator, not a [I]comparison[/I] one.
Copy linkTweet thisAlerts:
@marchnwauthorDec 11.2007 — Sorry I didn't explain it real well. Always hard for me to tell my problems in words.

I am on a page called Asmt_Details.asp. There is a sentence on that page with just several of the words being a link. Currently I have the link going to FSR_ScoreSheet.asp. There are different scales of assessments the users can select from on a previous page, so by the time they are here it is already decided what scale is being used. I now need my link to be dynamic. If the scale (called sScale in my db) being used is ECER then I need it to go to Extend_ScoreSheet.asp. If any other scale is being used it goes to FSR_ScoreSheet.asp.

Thanks
Copy linkTweet thisAlerts:
@nap0leonDec 11.2007 — fixing the missing = sign Kor noticed

[CODE]
if (sScale == a) {
self.location.href = 'pageA.asp';}
else {
self.location.href = 'pageB.asp';}
[/CODE]
×

Success!

Help @marchnw spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...