www.webdeveloper.com
Results 1 to 3 of 3

Thread: HTML button action - Can I use Javascript?

  1. #1
    Join Date
    Feb 2008
    Posts
    9

    Question HTML button action - Can I use Javascript?

    I wasn't sure if this should be posted in the HTML or Javascript area - myapologies for a wrong placement. Here is my question.

    I am working on a page that has an iframe that calls the following html code:

    Code:
    <html>
    <head>
    <title>Login</title>
    <script>
    <!--
    function SubmitAccCode()  {
    	var flag
    	if (document.thisform.code.value=='')  {
    		alert("You must enter a valid access code !") 
    	}
    	else {
    		flag = true
    		if (document.thisform.code.value.length==6)	{	//course access code
    			document.thisform.action = "http://hthu.coursehost.com/engine/authentication/registration/ChkAccessCode.asp?LID=1&ky=d_BPDiQVRgHzDiPRUmf_DgHzpSrOrRfz" 
    		}
    		else	{
    			flag = false	
    			alert("You must enter a valid  access code !") 
    		}
    		if (flag) {
    			document.thisform.method = "post" 
    			document.thisform.submit() 
    		}
    	}
    }
     
    function LoginSubmit() {
    	if (document.thisform.code) document.thisform.code.value = ""
    	if (document.thisform.Login.value !='' && document.thisform.Pwd.value != '') {
    		document.thisform.method = "post" ;
    		document.thisform.target = "_top" ;
    		document.thisform.action = "http://hthu.coursehost.com/Groups/Registration/HRLogIn1.asp?LID=1&ky=d_BPDiQVRgHzDiPRUmf_DgHzpSrOrRfz";
    		document.thisform.submit();
    	}else {
    		alert("Please enter your username and password.")
    	}
    	 
    }
     
    //-->
    </script>
    </head>
    
    <body>
    <center>
      <table width=500 border=0 bordercolor=#000000 cellspacing=0>
        <tr>
          <td><form name=thisform method=post ID="thisform">
              <h2>Username:
                <input type="text" name="Login" size="10" ID="Login">
                &nbsp;&nbsp;&nbsp; <br>
                Password:
                <input type="password" name="Pwd" size="10" ID="Pwd">
                &nbsp;&nbsp;
                > <a href="javascript:LoginSubmit();"><strong>Go Now!</strong></a></h2>
              <hr>
              <h5>Registration  &amp; Orientation for Physician Office Employees is FREE. Click here to <u><a href="http://hthu.coursehost.com/enroll/f41au2" target="_top">REGISTER</a></u><br>
                <br>
              <a href="http://hthu.coursehost.com/engine/authentication/login/password.asp?LID=1&ky=d_BPDiQVRgHzDiPRUmf_DgHzpSrOrRfz" target="_top"> Forgot your password? | </a><a href="http://hthu.coursehost.com/engine/Intranets/Course/PrivateCourses.asp?LID=1&ky=d_BPDiQVRgHzDiPRUmf_DgHzpSrOrRfz" target="_top">Course Catalog</a></h5>
            </form></td>
        </tr>
      </table>
    </center>
    </body>
    </html>
    you can see this in action here: http://www.hthu.net/PhysicianOffice.aspx

    I need to make a HTML button instead of the Go Now! Link - this way people can press Enter on the keyboard and advance to the next page. This current setup tells the iframe to have the top "window" (_top) to change (this can be seen in the function LoginSubmit().

    None the less... how can I make a button - I have tried the following:

    Code:
    <input name="Login" action="javascript:LoginSubmit();" type="button" value="Go Now!">
    But this does not work...

    Any ideas? Thanks for any help.

  2. #2
    Join Date
    Sep 2008
    Location
    Jackson MS
    Posts
    373
    Try onclick instead of action.

  3. #3
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Rather use a submit button and call the function onsubmit. Try this
    Code:
    <form name="thisform" method="post" id="thisform" onsubmit="LoginSubmit();return false">
    ...
    <input name="Login" type="submit" value="Go Now!">
    </form>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles