Javascript DOM HTML Input Submit formEnctype Property set

Introduction

Change the value of the formenctype attribute of a submit button to "application/x-www-form-urlencoded":

document.getElementById("mySubmit").formEnctype = "application/x-www-form-urlencoded";

View in separate window

<!DOCTYPE html>
<html>
<body>
<form action="/action_page_binary.asp" method="post">
  Name: <input type="text" name="fname" value="css"><br>
  <input type="submit" id="mySubmit" formenctype="text/plain" value="Submit">
</form>// ww w  .j a va2  s .  com
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("mySubmit").formEnctype = "application/x-www-form-urlencoded";
  document.getElementById("demo").innerHTML = "The value of the formenctype attribute was changed from 'text/plain' to 'application/x-www-form-urlencoded'.";
}
</script>

</body>
</html>



PreviousNext

Related