使用表单值构建href调用

时间:2013-01-25 15:12:27

标签: jquery html5

我有一个这样的简单形式:

<form action="emplist.html" method="post" rel="external">
Please enter one or several search items. Can be partial.
<label for="empid" class="ui-hidden-accessible">Employee ID:</label>
<input type="text" name="empid" id="s_empid" value="" placeholder="Employee ID"/>
<label for="lname" class="ui-hidden-accessible">Last Name:</label>
<input type="text" name="lname" id="s_lname" value="" placeholder="Last Name"/>
<label for="fname" class="ui-hidden-accessible">First Name:</label>
<input type="text" name="fname" id="s_fname" value="" placeholder="First Name"/>
<label for="department" class="ui-hidden-accessible">Department:</label>
<input type="text" name="department" id="s_department" value="" placeholder="Department"/>
<a href="emplist.html?eid=%s_empid&lnam=%s_lname&fnam=%s_fname&dep=%s_department" data-role="button" data-theme="b" data-icon="search" rel="external">Submit Search </a>
<input type="reset" value="Reset Form" data-theme="e" data-icon="delete"/>

当然不能正常工作,但一般的想法是用我正在捕获的表单参数构建href URL。

非常感谢你的帮助。

1 个答案:

答案 0 :(得分:2)

这就是the GET method的用途。在表单中使用它:

<form action="emplist.html" method="get" rel="external">
    <!-- all your fields should go here... -->
    <input type="submit" value="Submit Search" />
</form>