1
我想使用jquery重新形成窗體的目標網址 - 請參閱下文。任何想法,我錯了?非常感謝......簡單的javascript窗體行動方向
<!DOCTYPE html>
<html>
<head>
<style>
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<script>
// Needs to point at search page with eg: test.htm?s=SearchTerm&cat=3,7
// but I keep getting - test.htm?s=hh&cat1=3&cat2=0
$("#aSearch").click(function() {
$('form').attr('action', './test.htm?s=' + this.s + '&cat=' . this.cat1 + ',' + this.cat2);
});
</script>
<form name="advancedSearch" action="" method="get">
<input id="s" type="text" name="s" size="40" />
<select name="cat1">
<option value="0"> - - - </option>
<option value="3">Chardonnay (6)</option>
<option value="23">Gewurztraminer (1)</option>
<option value="24">Pinot Gris (1)</option>
<option value="4">Sauvignon Blanc (3)</option>
</select>
<select name="cat2">
<option value="0"> - - - </option>
<option value="2">Burgandy (6)</option>
<option value="7">Shiraz (1)</option>
</select>
<div><input id="aSearch" type="submit" value="Search" /></div
</form>
</body>
</html>
在你的情況'this'是你的下''元!不存在像's'或'cat1'這樣的字段/元素 – timaschew