How can I make an array using a loop which contains the name attributes of inputs inside a form tag, using javascript.
This is my code so far, but it doesn't seem to be working and I have looked at other similar questions to no avail.
<script type="text/javascript">
var inputnames[];
for (var i = 0; i < document.getElementsByTagName('input').length; i++)
{
inputnames[document.getElementsByTagName("input")[i].name]
};
document.write(inputnames)
</script>
The issue is that you're not actually adding the values to the array. Change
inputnames[document.getElementsByTagName("input")[i].name]
to
inputnames.push(document.getElementsByTagName("input")[i].name)