I am not a web-developer and want to understand the better way to pass variables. In the past I have used various ways to pass things to java script functions. I have never
Form elements can be used as a form of global variables - holding state that can be used and shared by all the javascript in a single page.
However, this could result in brittle and difficult to understand code.
I suggest keeping with passing parameters to functions, so long as you are in the context of a single page.
If you need to pass data to another page, then forms can make life easier - using a GET
form, the values on the form will be passed to the page referenced in the form action
attribute as key-value pairs. If you use the POST
method they will be transferred in the headers.