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

Discussion in 'Javascript' started by kev, Mar 22, 2008.

  1. kev

    kev Guest

    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./.
    kev, Mar 22, 2008
    #1
    1. Advertising

  2. kev

    Hal Rosser Guest

    > <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"
    Hal Rosser, Mar 22, 2008
    #2
    1. Advertising

  3. kev

    SAM Guest

    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>
    </form>

    > Please help....
    > Here is the code//////


    (snip)

    > <SCRIPT LANGUAGE="JavaScript">


    No! it is :

    <script type="text/javascript">

    > <!-- 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>



    --
    sm
    SAM, Mar 23, 2008
    #3
  4. kev

    kev Guest

    On Mar 22, 10:26 pm, "Hal Rosser" <> wrote:
    > > <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
    kev, Mar 23, 2008
    #4
  5. kev

    kev Guest

    On Mar 23, 6:28 am, SAM <>
    wrote:
    > 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>
    > </form>
    >
    > > Please help....
    > > Here is the code//////

    >
    > (snip)
    >
    > > <SCRIPT LANGUAGE="JavaScript">

    >
    > No! it is :
    >
    > <script type="text/javascript">
    >
    > > <!-- 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>

    >
    > --
    > sm


    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......
    kev, Mar 23, 2008
    #5
  6. kev

    SAM Guest

    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

    --
    sm
    SAM, Mar 23, 2008
    #6
  7. kev

    kev Guest

    On Mar 24, 3:59 am, SAM <>
    wrote:
    > 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
    >
    > --
    > sm


    hi sam,

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

    its working.............thanks a lot!!!!!!!!!!!!!!!!
    kev, Mar 24, 2008
    #7
  8. kev

    kev Guest

    On Mar 25, 12:13 am, kev <> wrote:
    > On Mar 24, 3:59 am, SAM <>
    > wrote:
    >
    >
    >
    >
    >
    > > 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

    >
    > > --
    > > sm

    >
    > 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
    kev, Mar 24, 2008
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MattB

    good host for a small site

    MattB, Dec 15, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    304
    Wayne P.
    Dec 16, 2004
  2. Claude
    Replies:
    0
    Views:
    337
    Claude
    Mar 7, 2004
  3. Shiperton Henethe
    Replies:
    117
    Views:
    2,122
    Andy Dingley
    Dec 22, 2004
  4. br3athe

    small updates to a big site

    br3athe, Jul 30, 2007, in forum: .NET
    Replies:
    0
    Views:
    420
    br3athe
    Jul 30, 2007
  5. Gilles

    Using a CMS for small site?

    Gilles, Jul 4, 2012, in forum: Python
    Replies:
    10
    Views:
    367
    Albert van der Horst
    Jul 13, 2012
Loading...

Share This Page