如何仅使用html获取输入元素的内容? [英] how to obtain the content of an input element with only html?

查看:72
本文介绍了如何仅使用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>

感谢您的帮助

推荐答案

如果将formget方法一起使用,则不必像这样设置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.

这篇关于如何仅使用html获取输入元素的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆