JavaScript method to get the action property of a web form

  • 2020-05-26 07:46:00
  • OfStack

This article illustrates how JavaScript gets the action properties of a web form. Share with you for your reference. The details are as follows:

JavaScript gets the action property of the web form, that is, the url address to which you want to submit, and sometimes if you need to submit to the current page, action may be set to null


<!DOCTYPE html>
<html>
<body>
<form id="frm1" action="jb51.php">
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>
<p>The value of the action attribute is:
<script>
document.write(document.getElementById("frm1").action);
</script>
</p>
</body>
</html>

The results are as follows:


The value of the action attribute is:jb51.php

I hope this article is helpful for you to design javascript program.


Related articles: