# How to find the action attribute and method of a form in JavaScript?

JavascriptObject Oriented ProgrammingFront End Technology

Action attribute and method are not inbuilt in a form, they have to be specified in a form externally. Javascript has provided document.action and document.method methods to get the action attribute and method of a form respectively. Let's discuss them individually.

## Action Attribute

### Example

In the following example, the action attribute of the form is found out using document.action attribute and displayed the result in the output.

Live Demo

<html>
<body>
<form id="frm1" action="/online_javascript_editor.php" method="get"></form>
<p id="demo"></p>
<script>
var act = document.getElementById("frm1").action;
document.getElementById("demo").innerHTML = act;
</script>
</body>
</html>

### Output

https://www.tutorialspoint.com/online_javascript_editor.php

## Method of a form

### Example

In the following example, the method of the form is found out using document.method attribute and displayed the result in the output.

Live Demo

<html>
<body>
<form id="frm1" action="/online_javascript_editor.php" method="get"></form>
<p id="demo"></p>
<script>
var met = document.getElementById("frm1").method;
document.getElementById("demo").innerHTML = met;
</script>
</body>
</html>

### Output

get
Published on 29-Jul-2019 14:10:38