admin管理员组文章数量:1410724
I need to build a form takes the user inputs and builds a query string, and then loads that URL
For example
<form id="form1" name="form1" method="post" action="">
<p>
<label>INPUT1
<input type="text" name="INPUT1" id="INPUT1" />
</label>
</p>
<p>
<label>INPUT2
<input type="text" name="INPUT2" id="INPUT2" />
</label>
</p>
<p>
<label>
<input type="submit" name="loadURL" id="loadURL" value="Submit" />
</label>
<br />
</p>
</form>
;model=<INPUT1>&cathegory=<INPUT2>
Is there a way to do this using just HTML, or does this need javascript? Any pointers on the easiest way to do this is appreciated.
I need to build a form takes the user inputs and builds a query string, and then loads that URL
For example
<form id="form1" name="form1" method="post" action="">
<p>
<label>INPUT1
<input type="text" name="INPUT1" id="INPUT1" />
</label>
</p>
<p>
<label>INPUT2
<input type="text" name="INPUT2" id="INPUT2" />
</label>
</p>
<p>
<label>
<input type="submit" name="loadURL" id="loadURL" value="Submit" />
</label>
<br />
</p>
</form>
http://website.&model=<INPUT1>&cathegory=<INPUT2>
Is there a way to do this using just HTML, or does this need javascript? Any pointers on the easiest way to do this is appreciated.
Share asked Dec 6, 2011 at 21:38 user547794user547794 14.5k38 gold badges108 silver badges153 bronze badges1 Answer
Reset to default 9Just set the action="/some/form/processor"
and the method="get"
(instead of post) and the fields in the form will be sent as the query string.
To get your example of http://website.&model=<INPUT1>&cathegory=<INPUT2>
you would have
<form id="form1" name="form1" method="get" action="http://website.">
<!-- or, more simply, since the website _is_ website. -->
<form id="form1" name="form1" method="get" action="/">
The input
names are used as the parameters, so your plete form would be
<form id="form1" name="form1" method="get" action="/">
<p>
<label>INPUT1
<input type="text" name="model" id="INPUT1" />
</label>
</p>
<p>
<label>INPUT2
<input type="text" name="cathegory" id="INPUT2" />
</label>
</p>
<p>
<label>
<input type="submit" name="loadURL" id="loadURL" value="Submit" />
</label>
<br />
</p>
</form>
本文标签: javascripttake HTML inputs and build a query stringStack Overflow
版权声明:本文标题:javascript - take HTML inputs and build a query string - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745018030a2637961.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论