Form name Property - Change the name of a form: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form

Description

Form name Property - Change the name of a form:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form id="myForm" name="form1" action="#">
  First name: <input type="text" name="fname" value="Donald"><br>
  Last name: <input type="text" name="lname" value="Duck"><br>
  <input type="submit" value="Submit">
</form>/*from   w w  w  .java 2 s .co m*/

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {
    document.getElementById("myForm").name = "newName";
    document.getElementById("demo").innerHTML = "The name of the form was changed from 'form1' to 'newName'.";
}
</script>

</body>
</html>

Related Tutorials