我有一个带有两个单选按钮(购买、租赁)和两个选择列表(最低价格、最高价格)的表单(如下)。
当您选择购买单选按钮时,它会调用其 JavaScript,并且下拉选项会更改为购买价格(100000 英镑、200000 英镑等)。当您选择出租单选按钮时,它再次调用它的 JavaScript 并显示出租价格(每周 250 英镑、每周 500 英镑等)。
下面的 JavaScript:
if (BuyRent=='buy') {
document.SearchForm.MaxPrice.options[0]=new Option("Price (Max)","150000000");
document.SearchForm.MaxPrice.options[1]=new Option("\u00A3100,000","100000");
document.SearchForm.MaxPrice.options[2]=new Option("\u00A3200,000","200000");
document.SearchForm.MinPrice.options[0]=new Option("Price (Min)","0");
document.SearchForm.MinPrice.options[1]=new Option("\u00A3100,000","100000");
document.SearchForm.MinPrice.options[2]=new Option("\u00A3200,000","200000");
} else if (BuyRent=='rent') {
while (document.SearchForm.MaxPrice.options.length>0) {
document.SearchForm.MaxPrice.options[0]=null;
}
while (document.SearchForm.MinPrice.options.length>0) {
document.SearchForm.MinPrice.options[0]=null
}
document.SearchForm.MaxPrice.options[0]=new Option ("Price (Max)","9999999");
document.SearchForm.MaxPrice.options[1]=new Option("\u00A3250","250");
document.SearchForm.MaxPrice.options[2]=new Option("\u00A3500","500");
document.SearchForm.MinPrice.options[0]=new Option("Price (Min)","0");
document.SearchForm.MinPrice.options[1]=new Option("\u00A3250","250");
document.SearchForm.MinPrice.options[2]=new Option("\u00A3500","500");
}
有没有办法告诉每个选项在提交表单时记住它的选择?