The value
property sets or gets the value attribute of the submit button.
The value attribute defines the text that is displayed on the submit button.
value |
Yes | Yes | Yes | Yes | Yes |
Return the value property.
var v = submitObject.value
Set the value property.
submitObject.value=text
Value | Description |
---|---|
text | The text displayed on the submit button |
A String type value representing the text displayed on the submit button.
The following code shows how to get the text displayed on a Submit button.
<!DOCTYPE html>
<html>
<body>
<!-- ww w .j ava2 s. c o m-->
<input type="submit" id="mySubmit" value="Submit form">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("mySubmit").value;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to change the text displayed on a Submit button.
<!DOCTYPE html>
<html>
<body>
<input type="submit" id="mySubmit" value="Submit form">
<button onclick="myFunction()">test</button>
<!-- ww w.ja v a2s. co m-->
<script>
function myFunction() {
document.getElementById("mySubmit").value = "newSubmitButtonValue";
}
</script>
</body>
</html>
The code above is rendered as follows: