如何仅使用html获取输入元素的内容?
我需要仅使用html将输入内容传递到表单的url,这可能吗?
I need to pass the content of the input to the url of the form with only html , is this possible ?
我需要做的是这样的:
<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>
感谢您的帮助
如果将form
与get
方法一起使用,则不必像这样设置action
.只需将其设置为<form action="./busPorMatricula.html">
,浏览器就会将密钥和值添加到URL.
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>
注意:由于StackOverflow中的安全性问题,您无法在代码段中看到结果.您可以在 http://output.jsbin.com/kelocu 中看到它.提交form
后,将使用URL中的键和值转到google.com
.
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.