document.forms[variable].submit var=variable how to pass a variable So for example if I run document.forms[variable].submit and change the word varaible to a static item then it gets the id from the form.. What I am trying to do use var =x or var=variable Whats in the var is actually the id it will be submitting in javascript
there is multiple forms on one page and I am using the <form id="XXX" then XXX is used on selecting which form. if I manually type in the XXX document.forms["XXX"].submit it works like a charm however if try to dynamic do it then it doesn't work. I have tried var a=xxx; document.forms.a.submit document.forms.(a).submit document.forms.[a].submit and a bunch more I am not sure of the proper dynamic way to put in it. I have tried to google and look at other forums etc.. no such luck I am not sure of the proper way.
forms["XXX"] is an object and cannot be replaced by a value, the property a of forms.a is the name value of the specific form. So you can return the forms object like this: const formA = document.forms.a, and then apply submit with: formA.submit.
I understand its a object haha thank you thats what I was looking >> const formA = document.forms.a, and then apply submit with: formA.submit. I did just end up rebuilding most of the form today though it works. But now I know how to do it thanks again