Form submission
When a form gets submitted, an event can be triggered. This can be achieved in different ways, and one of them is to add to the form
element the onsubmit
attribute.
<form onsubmit="doSomething()">
The function that is listed there will get triggered whenever input of type submit
is submitted.
<input type="submit" value="send">
We can do more with the HTML of the form
element; for example, we can redirect to another page. We have to specify the way we want to send the form values using the method
attribute and the location page using the action
attribute.
<form action="anotherpage.html" method="get" onsubmit="doStuff()">
Don't worry about the get
for now; this just means that values get sent via the URL. URLs look like this when you use get
:
www.example.com/anotherpage.html?name=edward
After the question mark, the variables that are sent along are shown...