Roberto Fernandez Diaz
Roberto Fernandez Diaz

Reputation: 804

how to obtain the content of an input element with only html?

I need to pass the content of the input to the url of the form with only html , is this possible ?

What i need to do is something like this :

<div>
    <ul>
        <li><a href="./busesFuncionando.html">Buses Funcionando</a></li>
        <form action="./busPorMatricula.html?matricula=????">

        <!-???? has to be substitute by the content of the input->

        Inserte la matricula del autobus a buscar :
            <input type="text" name="matricula"/>
            <input type="submit" value="Buscar"/>
        </form>
    </ul>
</div>

Thanks for the help

Upvotes: 1

Views: 52

Answers (1)

Mosh Feu
Mosh Feu

Reputation: 29277

If you are using the form with get method, you don't have to set the action like this. Just set it to <form action="./busPorMatricula.html"> and the browser will add the key and the value to the URL.

<form action="https://www.google.co.il/">
  <input type="text" name="matricula" />
  <input type="submit" value="submit" />
</form>

Note: You can't see the result in the snippet because the security issues in StackOverflow. You can see it in: http://output.jsbin.com/kelocu. After you submit the form you will go to google.com with the key and value in the URL.

Upvotes: 1

Related Questions