【发布时间】:2018-06-09 11:10:55
【问题描述】:
我使用 Phonegap 创建了一个基于 JavaScript 的离线安卓应用。 index.html中有四种形式用于在数据库中搜索:
<form onsubmit="s1(); return false;">
<input id="search1" type="text" maxlength="255" placeholder="Search in Titles only" value="" />
<input type="submit" value="Go" />
</form>
<form onsubmit="s2(); return false;">
<input id="search2" type="text" maxlength="255" placeholder="Search in Titles + Contents" value="" />
<input type="submit" value="Go" />
</form>
<form onsubmit="scat(); return false;">
<input id="cat" type="text" maxlength="255" placeholder="Search in Categories" value="" />
<input type="submit" value="Go" />
</form>
<form onsubmit="gotoid(); return false;">
<input id="articleid" type="text" maxlength="255" placeholder="Find based on ID" value="" />
<input type="submit" value="Go" />
</form>
以下是页内脚本:
function s1() {
window.location.href = "search1.html?" + document.getElementById("search1").value.trim().replace(/\s+/g, "+");
}
function s2() {
window.location.href = "search2.html?" + document.getElementById("search2").value.trim().replace(/\s+/g, "+");
}
function scat() {
window.location.href = "cat.html?" + document.getElementById("cat").value.trim().replace(/\s+/g, "+");
}
function gotoid() {
window.location.href = "id.html#" + document.getElementById("articleid").value.trim().replace(/\s+/g, "");
}
问题是页面很脏。我尝试将这四种形式合二为一,通过添加<select> 和<options> 来保持它们的功能,但我无法使其工作。
任何建议,无论是CSS、HTML、JavaScript,还是它们的组合(但不是 jQuery)都将不胜感激。
【问题讨论】:
标签: javascript html css