Am using a Javascript for my small site.....


K

kev

Hi,

Am using java script for a mini site. what is my problem is , once am
selecting a user name from the list, and then typing a password, when
a user press enter button, it is not taking .....

user have to manually use mouse to click the submit button...

can i make it easy for the user by pressing the enter button??

Please help....

Here is the code//////
form part of my file.........


<center><form name=login >
<table border=1 cellpadding=3>

<tr><td colspan=2 align=center><font size="+2"><b>Members-Only Area!</
b></font></td></tr>
<tr><td>Username:</td><td><select name=memlist>
<option value='x'>
<option value='John Smith|42691|NGLOQEMM'>John Smith
<option value='Peter Jones|52219|GNLVAPMV'>Peter Jones
<option value='Sue Brown|18215|PXAPGWKY'>Sue Brown
<option value='Sally West|64403|NUIRTURT'>Sally West
<option value='John|16419|VHYZAJUV'>John
</select></td></tr>
<tr><td>Password:</td><td><input type=password size=10 maxlength=8
name=pass></td></tr>
<tr><td colspan=2 align=center><input type="button"name= submit
value="Submit" onclick="check(this.form);" ></td>
</tr>
</table>
</form>
if u want the entire file....here it goes.........


<html>
<title>a</title>
<head>
</head>
<body>

<center><form name=login >
<table border=1 cellpadding=3>

<tr><td colspan=2 align=center><font size="+2"><b>Members-Only Area!</
b></font></td></tr>
<tr><td>Username:</td><td><select name=memlist>
<option value='x'>
<option value='John Smith|42691|NGLOQEMM'>John Smith
<option value='Peter Jones|52219|GNLVAPMV'>Peter Jones

</select></td></tr>
<tr><td>Password:</td><td><input type=password size=10 maxlength=8
name=pass></td></tr>
<tr><td colspan=2 align=center><input type="button"name= submit
value="Submit" onclick="check(this.form);" ></td>
</tr>
</table>
</form>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var params=new Array(4);
var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
function check(form) {
which=form.memlist.selectedIndex;
choice = form.memlist.options[which].value+"|";
if (choice=="x|") {
alert("Please Select Your Name From The List");
return;
}
p=0;
for (i=0;i<3;i++) {
a=choice.indexOf("|",p);
params=choice.substring(a,p);
p=a+1;
}
h1=makehash(form.pass.value,3);
h2=makehash(form.pass.value,10)+" ";
if (h1!=params[1]) {
alert("Incorrect Password!"); return; };
var page="";
for (var i=0;i<8;i++) {
letter=params[2].substring(i,i+1)
ul=letter.toUpperCase();
a=alpha.indexOf(ul,0);
a-=(h2.substring(i,i+1)*1);
if (a<0) a+=26;
page+=alpha.substring(a,a+1); };
top.location=page.toLowerCase()+".html";
}
function makehash(pw,mult) {
pass=pw.toUpperCase();
hash=0;
for (i=0;i<8;i++) {
letter=pass.substring(i,i+1);
c=alpha.indexOf(letter,0)+1;
hash=hash*mult+c;
}
return(hash);
}
// End -->
</script>
</center>
</body>
</html>

if u r trying to run this file as live, find out the following info ::

User name: John Smith
password is : password
file name in the same folder : mainpage.html

process:
once user name and password is selected, and once submit button
clicks, it will take you to mainpage.html......

Hope u got it....

let me know anything more if u needed....

and please
Please help./.
 
Ad

Advertisements

H

Hal Rosser

<table border=1 cellpadding=3>

<tr><td colspan=2 align=center><font size="+2"><b>Members-Only Area!</
b></font></td></tr>
<tr><td>Username:</td><td><select name=memlist>
<option value='x'>
<option value='John Smith|42691|NGLOQEMM'>John Smith
<option value='Peter Jones|52219|GNLVAPMV'>Peter Jones
<option value='Sue Brown|18215|PXAPGWKY'>Sue Brown
<option value='Sally West|64403|NUIRTURT'>Sally West
<option value='John|16419|VHYZAJUV'>John
</select></td></tr>
<tr><td>Password:</td><td><input type=password size=10 maxlength=8
name=pass></td></tr>
<tr><td colspan=2 align=center><input type="button"name= submit
value="Submit" onclick="check(this.form);" ></td>
</tr>
</table>
</form>
if u want the entire file....here it goes.........

I did not copy/[paste/ and try your code with this modification.but..
this modification may be what you're after, since you want the keyboard's
"enter" button to cause the form to submit.
Change your last "input" element to type="submit" instead of type="button"
 
S

SAM

kev a écrit :
Hi,

Am using java script for a mini site. what is my problem is , once am
selecting a user name from the list, and then typing a password, when
a user press enter button, it is not taking .....

user have to manually use mouse to click the submit button...

why that ?
as soon as you are in a text-field
the key Enter can submit the form ... !
No need JS for that.

About your password there is a very simple way to do :

<form onsubmit="top.location=this.pass+'.html';">
Enter your password : <input type=password name=pass>
and press the Enter key.
</form>

That will send to the page 'toto.html' if password is 'toto'.
If a wrong password is set you'll get the page 404 (Not Found) of the
server.
can i make it easy for the user by pressing the enter button??

for your code :
put the call to your function in an onsubmit in the tag form

<form action="#" onsubmit="return check(this)">

blah blah

<input type=submit>
Please help....
Here is the code//////
(snip)

<SCRIPT LANGUAGE="JavaScript">

No! it is :

<!-- Begin
var params=new Array(4);
var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
function check(form) {
which=form.memlist.selectedIndex;

var which = form.memlist.selectedIndex;
if(which==0) {
alert('Please Select Your Name From The List');
return false;
}
choice = form.memlist.options[which].value;

var choice = form.memlist.options[which].value;
var params = choice.split('|');
h1=makehash(form.pass.value,3);
h2=makehash(form.pass.value,10)+" ";

if (h1!=params[1]) {
alert("Incorrect Password!");
return false;
}
var page="";
for (var i=0;i<8;i++) {
letter=params[2].substring(i,i+1)
ul=letter.toUpperCase();

// directly :
var ul = params[2].substring(i,i+1).toUpperCase();
var a;
a=alpha.indexOf(ul,0);
a-=(h2.substring(i,i+1)*1);
if (a<0) a+=26;
page+=alpha.substring(a,a+1); };
top.location=page.toLowerCase()+".html";

// no ! use the form and its submition feature :

form.action = page.toLowerCase()+".html";
return true;
 
K

kev

<center><form name=login >
<table border=1 cellpadding=3>
<tr><td colspan=2 align=center><font size="+2"><b>Members-Only Area!</
b></font></td></tr>
<tr><td>Username:</td><td><select name=memlist>
<option value='x'>
<option value='John Smith|42691|NGLOQEMM'>John Smith
<option value='Peter Jones|52219|GNLVAPMV'>Peter Jones
<option value='Sue Brown|18215|PXAPGWKY'>Sue Brown
<option value='Sally West|64403|NUIRTURT'>Sally West
<option value='John|16419|VHYZAJUV'>John
</select></td></tr>
<tr><td>Password:</td><td><input type=password size=10 maxlength=8
name=pass></td></tr>
<tr><td colspan=2 align=center><input type="button"name= submit
value="Submit" onclick="check(this.form);" ></td>
</tr>
</table>
</form>
if u want the entire file....here it goes.........

I did not copy/[paste/ and try your code with this modification.but..
this modification may be what you're after, since you want the keyboard's
"enter" button to cause the form to submit.
Change your last "input" element  to type="submit" instead of type="button"- Hide quoted text -

- Show quoted text -

Nope,
its not working :(
the only option i have is select user name, type password and then
press TAB, then enter.....

But by default, the page not taking it if i press enter button without
TAB.....

Kev
 
K

kev

kev a écrit :
Am using java script for a mini site. what is my problem is , once am
selecting a user name from the list, and then typing a password, when
a user press enter button, it is not taking .....
user have to manually use mouse to click the submit button...

why that ?
as soon as you are in a text-field
the key Enter can submit the form ... !
No need JS for that.

About your password there is a very simple way to do :

<form onsubmit="top.location=this.pass+'.html';">
Enter your password : <input type=password name=pass>
and press the Enter key.
</form>

That will send to the page 'toto.html' if password is 'toto'.
If a wrong password is set you'll get the page 404 (Not Found) of the
server.
can i make it easy for the user by pressing the enter button??

for your code :
put the call to your function in an onsubmit in the tag form

<form action="#" onsubmit="return check(this)">

blah blah

<input type=submit>
Please help....
Here is the code//////
(snip)

<SCRIPT LANGUAGE="JavaScript">

No! it is :

<!-- Begin
var params=new Array(4);
var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
function check(form) {
which=form.memlist.selectedIndex;

var which = form.memlist.selectedIndex;
if(which==0) {
     alert('Please Select Your Name From The List');
     return false;
     }
choice = form.memlist.options[which].value;

var choice = form.memlist.options[which].value;
var params = choice.split('|');
h1=makehash(form.pass.value,3);
h2=makehash(form.pass.value,10)+" ";

if (h1!=params[1]) {
     alert("Incorrect Password!");
     return false;
     }
var page="";
for (var i=0;i<8;i++) {
letter=params[2].substring(i,i+1)
ul=letter.toUpperCase();

// directly :
var ul = params[2].substring(i,i+1).toUpperCase();
var a;
a=alpha.indexOf(ul,0);
a-=(h2.substring(i,i+1)*1);
if (a<0) a+=26;
page+=alpha.substring(a,a+1); };
top.location=page.toLowerCase()+".html";

// no ! use the form and its submition feature :

form.action = page.toLowerCase()+".html";
return true;
}
function makehash(pw,mult) {
pass=pw.toUpperCase();
hash=0;
for (i=0;i<8;i++) {
letter=pass.substring(i,i+1);
c=alpha.indexOf(letter,0)+1;
hash=hash*mult+c;
}
return(hash);
}
// End -->
</script>

Hey thanks a lot for the reply...

For the password,

I cant do that, for many internal reasons....

I need to have like the design i mentioned...

And regarding the changes,

Its not working....may be i had not understood correctly, i dont
know...

would you mind sending me the rite changed coding to me....and also
test at your side....

so that, the moment i select John smith from the list, and type the
password as "password", and hit enter , it should show
mainpage.html....

thanks......
 
S

SAM

kev a écrit :
would you mind sending me the rite changed coding to me....and also
test at your side....

Here a zipped folder with 3 files :
<http://cjoint.com/?dxx1gmlmTB>

Each file in its own charset (ISO-8859-1 WINDOW-1252 UTF-8)

Take care using your NotePad it is correctly fixed
(in the charset of the file you open)

The code picked in your post was full of incorrect characters.
so that, the moment i select John smith from the list, and type the
password as "password", and hit enter , it should show
mainpage.html....

it runs OK
 
Ad

Advertisements

K

kev

kev a écrit :




Here a zipped folder with 3 files :
<http://cjoint.com/?dxx1gmlmTB>

Each file in its own charset (ISO-8859-1  WINDOW-1252  UTF-8)

Take care using your NotePad it is correctly fixed
(in the charset of the file you open)

The code picked in your post was full of incorrect characters.


it runs OK

hi sam,

you are god to me now...........

its working.............thanks a lot!!!!!!!!!!!!!!!!
 
Ad

Advertisements

K

kev

hi sam,

you are god to me now...........

its working.............thanks a lot!!!!!!!!!!!!!!!!- Hide quoted text -

- Show quoted text -

I have one more question for u .........

In the files which you have sent or the files which i have, what ever
it may be,

its a password protected file...

but then, a person who knows the path of that file can easily access
the file by just copyin it and pasting in the address bar...

is there any way to prevent it??

my friend suggested my that we can pass parameters from login page to
the main page so that if and if only the paraments checking is true,
it will display the file...or else it shud show some other file...

he also suggested to check the previous page using some prevpage()
function.....

so that if the previous page = " " , if it is true it will display the
contents, or else , it will not....

will this both cases work??

if yes , please help me in that....

or do u have any other ideas regarding this ???

please help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top