这是基本形式,它们有一个预定义的值,用于创建链接,但我的问题是值因位置而异。请帮忙!
<input type="radio" id="iconapp1" name="department" value="1250"/><label for="iconapp1"></label>
<input type="radio" id="iconapp2" name="department" value="944"/ checked><label for="iconapp2"> </label>
<input type="radio" id="iconapp3" name="department" value="4"/><label for="iconapp3"></label>
<input type="radio" id="iconapp4" name="department" value="1254"/><label for="iconapp4"></label>
<input type="radio" id="enginemake1" name="enginemake" value="6" checked/><label for="enginemake1">Chevrolet</label><br>
<input type="radio" id="enginemake2" name="enginemake" value="8"/><label for="enginemake2">Chrysler</label><br>
<input type="radio" id="enginemake3" name="enginemake" value="7"/><label for="enginemake3">Ford</label><br>
<select id="powerrange" name="powerrange">
<option id="powerrange1" value="128">200 HP</option>
<option id="powerrange2" value="178">250 HP</option>
<option id="powerrange3" value="228" selected>300 HP</option>
<option id="powerrange4" value="278">350 HP</option>
</select>
<input type="radio" id="location1" name="location" value="store" checked/><label for="location1">America</label><br>
<input type="radio" id="location2" name="location" value="store.au"/><label for="location2">Australia</label><br>
我有这个正在运行的脚本,它创建了一个来自上一个表单的链接,但我的问题是值(部门,Enginemake和功率范围)根据位置而不同。
例如,如果选择OCEANICA使用Engine Make Value 2,AMERICA选择Use Engine Make Value 1,那可能吗?
<script type="text/javascript">
function goToPage(){
var location = $('input[name=location]:checked').val();
var department = $('input[name=department]:checked').val();
var enginemake = $('input[name=enginemake]:checked').val();
var powerrange = document.getElementById("powerrange").value;
window.location.href = "http://"+location+".domain.com/catalog.aspx?section=-"+department+"-"+enginemake+"-"+powerrange+"-";
}
</script>
答案 0 :(得分:0)
您是否想要更改&#34;位置&#34;的点击事件中的其他字段的选择?领域?如果是这样,$(document).ready
内的这样的东西就可以了:
$("input[name='location']").click(function(){
switch($(this).val()){
case 'store':
$("#enginemake").attr("checked", "true");
break;
//insert logic for other selections
}
})
可以使用.hide()
和.show()
代替.attr()
调用来完成类似的操作,以根据选择显示不同的选项。