/    Sign up×
Community /Pin to ProfileBookmark

password sequence

hi ya

i need help with creating a password on my website
i want to create an buttons which are of images
i want about 8 button images on the page and for a user to enter a site, they need to click on a sequence of images before they can enter. so for example they would need to click 4 different images before they can enter.

i would be very grateful if someone could help me

here is what i tries with just 4 images but cannot get it to work

<html>
<head>
</head>

<script type = “text/javaScript”>

function doSomething(k)

var n = 0;
var counter = 0;
counter = counter = 1;

{
if(n==0 && k==3){
n=1}
else if (n==1 && k==1){
n=2}
else{
n=0
}

window.alert(“k= ” + k+ “n = ” + n)
if (n==2){
window.open(‘http://www.yahoo.com‘)
}
else if (counter ==2) {
window.alert (‘sorry wrong password’)
counter=0
n=0
}
}

</script>

<body>

<button id = foo1 onClick = “doSomething(1)”>
<img src = “1.jpg” width = 50 height = 50>
</button>

<button id = foo2 onClick = “doSomething(2)”>
<img src = “2.jpg” width = 50 height = 50>
</button>

<button id = foo3 onClick = “doSomething(3)”>
<img src = “3.jpg” width = 50 height = 50>
</button>

<button id = foo4 onClick = “doSomething(4)”>
<img src = “4.jpg” width = 50 height = 50>
</button>

</body>
</html>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@batfinkApr 20.2004 — [code=php]<html>
<head>
<script type ="text/javaScript">
var n = 0;
var counter = 0;
function doSomething(k)
{
counter++;
if(n==0 && k==3){n=1}
else if(n==1 && k==1){n=2}
else{n=0;}

window.alert("k = " + k+ " n = " + n)
if (n==2){window.open('http://www.yahoo.com')}
else if (counter ==2)
{
window.alert ('sorry wrong password')
counter=0
n=0
}
}

</script>
</head>
<body>

<button id = foo1 onClick ="doSomething(1)">
<img src = "1.jpg" width="50" height="50">
</button>

<button id = foo2 onClick ="doSomething(2)">
<img src = "2.jpg" width ="50" height ="50">
</button>


<button id = foo3 onClick="doSomething(3)">
<img src = "3.jpg" width="50" height ="50">
</button>

<button id = foo4 onClick="doSomething(4)">
<img src = "4.jpg" width="50" height="50">
</button>

</body>
</html>[/code]
Copy linkTweet thisAlerts:
@neil9999Apr 20.2004 — [code=php]
<html>
<head>
<script type ="text/javaScript">
var n=0;
var c=true;
//On the next line, enter order in which buttons must be clicked.
var a=["but1","but4","but3"]
function check(w){
if(w!=a[n]){
c=false;
}
n++
if(n==a.length && c){
alert("Correct!");
//On the next line, enter website to go to if sequence is correct
window.location="http://www.google.co.uk";
}
else if(n==a.length){
alert("Wrong!")
n=0;
c=true;
}
}
</script>
</head>
<body>

<button id = "foo1" onClick ="check('but1')">
<img src = "1.jpg" width="50" height="50">
</button>

<button id = "foo2" onClick ="check('but2')">
<img src = "2.jpg" width ="50" height ="50">
</button>


<button id = "foo3" onClick="check('but3')">
<img src = "3.jpg" width="50" height ="50">
</button>

<button id = "foo4" onClick="check('but4')">
<img src = "4.jpg" width="50" height="50">
</button>
...carry on entering buttons like this.
</body>
</html>
[/code]


This script allows you to have any sequence, any length. It waits until (in this case 3) buttons have been pressed, tells you if the sequence you entered was correct, if it is, it redirects to another site. If not it tells them so.

Bear in mind all similar javascripts aren't secure, people can just view the source code to find the password protected site.

Hope this helps,

Neil
×

Success!

Help @hemlata 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 5.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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