根据用户输入动态创建HTTP链接

creating http link dynamically according to the user input

本文关键字:创建 HTTP 链接 动态 输入 用户      更新时间:2023-09-26

我现在正在构建一个包含搜索框的网页。如何创建根据搜索框上的输入而更改的搜索查询?

<input type=text name="searchquery"/>
<input type=button name=search value="search" onClick=changeQuery()/>
changeQuery(){
????
}

无论如何,我设法得到了所需的输出…

<input type=text id='sq' name="searchquery"/>
<input type=button name=search value="search" onClick=changeQuery()/>
changeQuery(){
var input_query=document.getElementById('sq').value;
window.location="http://www.google.com/search?q="+input_query+"myString";
}