Get current value of the submit button which is displayed on the button itself in JavaScript

Description

The following code shows how to get current value of the submit button which is displayed on the button itself.

Example


<!DOCTYPE html>
<html>
<head>
<script language="JavaScript1.1">
function getValue(){<!--   w ww . j a  va 2  s  .c om-->
alert("The value of this submit button is " + document.myForm.elements[1].value);
}
</script>
</head>
<body>
<form name="myForm">
<input type=TEXT value="First Box" name="myText">
<input type=SUBMIT value="Submit" name="mySubmit" onClick='getValue()'>
</form>
</body>
</html>

Click to view the demo

The code above generates the following result.

Get current value of the submit button which is displayed on the button itself in JavaScript
Home »
  Javascript Tutorial »
    Form »
      Button
Javascript Tutorial Button
Access form button with its name through do...
Access form with form name through document...
Add click action to a Button in JavaScript
Add click event handler for input button in...
Add click event handler to input onClick ev...
Change input button color and background co...
Get current value of the submit button whic...
List properties from a form button in JavaS...
Return false in form button click event to ...
Use Image as the submit button in JavaScrip...