/    Sign up×
Community /Pin to ProfileBookmark

Problem with simple script!!

Hi,

I’m using a simple bit of JS to confirm a user meant to click on a link using the following code:

[COLOR=red]<script language=”JavaScript”>
function myverify(type, id) {
if(type == “forfeit” and confirm(“Are you sure you want to forfeit this game? You will receive a lower rating.”) == true) {
window.location = ‘scripts/forfeit.php?game=’;
}
if(type == “cancel” and confirm(“Are you sure you want to cancel this game?”) == true) {
window.location = ‘scripts/cancelpendinggame.php?game=’;
}
}
</script>[/COLOR]

and calling it using:

[COLOR=red]<a href=”#” onClick=”myverify(‘forfeit’, ‘5’); return false;”>Forfeit</a>[/COLOR]

Anyone know why this isn’t working?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@spadgosFeb 09.2005 — Change your "and"s to "&&"

[CODE]if (type == "forfeit" && confirm("...")) {[/CODE]
...and similarly for the "cancel" line

(you don't need to have " == true", either)
Copy linkTweet thisAlerts:
@KierenauthorFeb 09.2005 — AH!!

Thanks ?

Kieren
×

Success!

Help @Kieren 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.16,
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,
)...