I have a form to send data by GET
and I want to send additional data by appending it to the URL, the code is:
<form action="/Libro?accion=salvar" method="get">
<label for="titulo">Titulo</label>
<br>
<input type="text" id="titulo" name="titulo">
<br>
<br>
<label for="categoria">Categoria</label>
<br>
<input type="text" id="categoria" name="categoria">
<br>
<input type="submit" value="Guardar cambios">
</form>
When I submit, the following url is sent:
Libro?titulo=Inferno&categoria=Literatura
But the variable accion=salvar
I want to send is not being sent, I don't know how to send that additional variable to the other page at the same url.
add a field
hidden
Your complete code:
You can send it this way:
First of all, in your
action
you should not include theGET
by methodURL
, you are already declaring that you are going to submit the form by methodGET
.You can include a
input
of typehidden
and that's where you add the save value.Although instead of using the method I
GET
would use the methodPOST
, the difference is the way of sending the data, itGET
sends the data using theURL
andPOST
it sends them by standard input and it does not show anything in yourURL
.