+ Reply to Thread
Results 1 to 5 of 5

Thread: JavaScript Issue - Please Help

  1. #1
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    JavaScript Issue - Please Help

    It's that time of the day again when your brain shuts down

    Anyone know why this doesn't work? I really don't see why...

    HTML Code:
    <script type="text/javascript" src="scripts/sha1.js"></script>
    <script type="text/javascript">
    function $(id) {
    	return document.getElementById(id);
    }
    
    function Submit() {
    	if (!document.login.user.value) {document.login.user.style.backgroundColor="#FF7575"; return false;}
    	if (!$("pass").value) {$("pass").style.backgroundColor="#FF7575"; return false;}
    	document.login.pass.value = hex_sha1($("pass").value);
    	document.login.submit();
    	return true;
    }
    </script>
    </head>
    <body><br />
    <h1 align="center">SQL Administration</h1><form action="#" method="post" name="login">
    <input type="hidden" name="do" value="login" />
    <input type="hidden" name="pass" value="" />
    <table border="0" align="center">
    <tr><td>Username:</td>
    <td><input type="text" name="user" onfocus="this.style.backgroundColor='#FFFFCC';" onblur="this.style.backgroundColor='#FFFFFF';" /></form></td></tr>
    <tr><td>Password:</td>
    <td><input type="password" id="pass" onfocus="this.style.backgroundColor='#FFFFCC';" onblur="this.style.backgroundColor='#FFFFFF';" /></td></tr>
    </table><br />
    <center><input type="button" value=" Login " id="submit" /></center>
    <script type="text/javascript">
    $("submit").onclick = Submit;
    document.login.onsubmit = Submit;
    </script>
    I get an error saying that document.login.submit() is not a function? Any help would be appreciated!
    Last edited by Twinkie; 04-18-2009 at 09:16 PM.

  2. #2
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    Re: JavaScript Issue - Please Help

    i'm not sure (because javascript is definatly not something i'm proficient at, not even close) but can that idea even work, seeing as the document.login.submit() is inside the head section. i've only ever seen that used in the body section.

  3. #3
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: JavaScript Issue - Please Help

    Nope, I tried it but it didn't work. The function is not called until the body is loaded, or the user could not submit the form. Otherwise, the form would submit as soon as the page loads. Thanks for trying to help

  4. #4
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    Re: JavaScript Issue - Please Help

    why can't you just use a submit type input instead of a button type input?

  5. #5
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: JavaScript Issue - Please Help

    I am using this diversion so I can hash the password before sending it using an encryption library. If I was using that same form for that instead of an inconspicuous hidden field, the user would wonder why his password enlarged 20 characters or so when submitting. Anyway, I found the error was that the id of the button was submit, which is apparently a bad thing. This the the type of generic error that makes you want to pull out your hair...

    Thanks a lot for your help, I have you rep.
    Last edited by Twinkie; 04-18-2009 at 10:28 PM.

+ Reply to Thread

Similar Threads

  1. integration issue between support, cpanel, forum ????
    By holeepassion in forum Free Hosting
    Replies: 4
    Last Post: 12-14-2008, 09:50 PM
  2. Making a site JavaScript dependent - pros/cons?
    By Tarzan in forum Programming Help
    Replies: 8
    Last Post: 07-11-2008, 10:08 AM
  3. drop down menus with JavaScript disabled?
    By sifaka in forum Free Hosting
    Replies: 1
    Last Post: 05-15-2008, 10:46 AM
  4. javascript and external javascript files problem
    By delon in forum Programming Help
    Replies: 6
    Last Post: 04-27-2008, 12:41 AM
  5. XML and Javascript
    By cuteboytm in forum Graphics & Webdesign
    Replies: 1
    Last Post: 09-21-2007, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers