2015-12-30 35 views
1

我需要將輸入的內容通過html傳遞給表單的url,這可能嗎?如何用html獲取輸入元素的內容?

什麼,我需要做的是這樣的:

<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> 

感謝您的幫助

+2

至少,您可能必須使用JavaScript。 – Lock

+0

更不用說你的HTML無效了。 – j08691

回答

1

如果您使用的是formget方法,你不必設置action這樣。只需將其設置爲<form action="./busPorMatricula.html">,瀏覽器就會將該鍵和值添加到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

+0

感謝這對我有用 –