我的jsp页面代码:<table width="580" >
<form name="form1" method="post" action="">
<tr>
<td class="bar_td"><strong>人</strong>
<c:choose>
<c:when test="${a}">
<select id="amount" name="amount" onchange="javascript:TestTable();" style="width: 112px">
<option value="0" >--请选择人数--</option>
<option value="1" <c:if test="${amount==1}"> selected</c:if>>1</option>
<option value="2" <c:if test="${amount==2}"> selected</c:if>>2</option>
<option value="3" <c:if test="${amount==3}"> selected</c:if>>3</option>
<option value="4" <c:if test="${amount==4}"> selected</c:if>>4</option>
<option value="5" <c:if test="${amount==5}"> selected</c:if>>5</option>
<option value="6" <c:if test="${amount==6}"> selected</c:if>>6</option>
<option value="7" <c:if test="${amount==7}"> selected</c:if>>7</option>
<option value="8" <c:if test="${amount==8}"> selected</c:if>>8</option>
<option value="9" <c:if test="${amount==9}"> selected</c:if>>9</option>
</select>
(人数选择)
</c:when>
<c:otherwise>
人数:${amount }
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td align="center">
<input type="button" value="修改确认" onclick="booking();"/>
</td>
</tr>
</form>
</table>
js代码:
function booking() {
var ObjTrue;
if (document.form1.amount.value=="0") {
alert("请选择人数");
document.form1.amount.focus();
return false;
}
document.form1.action="xx.action";
document.form1.submit();
}
在FireFox中每次点确认修改时select的selected项就变为“请选择人数”这一项,IE不会,为什么啊?怎么解决啊?怎么兼容啊?
<form name="form1" method="post" action="">
<tr>
<td class="bar_td"><strong>人</strong>
<c:choose>
<c:when test="${a}">
<select id="amount" name="amount" onchange="javascript:TestTable();" style="width: 112px">
<option value="0" >--请选择人数--</option>
<option value="1" <c:if test="${amount==1}"> selected</c:if>>1</option>
<option value="2" <c:if test="${amount==2}"> selected</c:if>>2</option>
<option value="3" <c:if test="${amount==3}"> selected</c:if>>3</option>
<option value="4" <c:if test="${amount==4}"> selected</c:if>>4</option>
<option value="5" <c:if test="${amount==5}"> selected</c:if>>5</option>
<option value="6" <c:if test="${amount==6}"> selected</c:if>>6</option>
<option value="7" <c:if test="${amount==7}"> selected</c:if>>7</option>
<option value="8" <c:if test="${amount==8}"> selected</c:if>>8</option>
<option value="9" <c:if test="${amount==9}"> selected</c:if>>9</option>
</select>
(人数选择)
</c:when>
<c:otherwise>
人数:${amount }
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td align="center">
<input type="button" value="修改确认" onclick="booking();"/>
</td>
</tr>
</form>
</table>
js代码:
function booking() {
var ObjTrue;
if (document.form1.amount.value=="0") {
alert("请选择人数");
document.form1.amount.focus();
return false;
}
document.form1.action="xx.action";
document.form1.submit();
}
在FireFox中每次点确认修改时select的selected项就变为“请选择人数”这一项,IE不会,为什么啊?怎么解决啊?怎么兼容啊?
还是你代码的问题
TestTable()的代码呢
var initAmount = document.getElementById("initAmount").value;
initAmount = parseInt(initAmount);
var Samount3 = document.getElementById("amount").value;
var Allamount = parseInt(Samount3);
var content = unescape("<table>");var contentEnd = unescape("</table>");
for(var i=initAmount; i<Allamount; i++) {
var TableContent=unescape("<table width=\"100%\" border=\"0\" frame=\"void\" rules=\"cols\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\"><tr>"
+ "<td width='15%'>姓 名<span class=\"red2\">" + (i+1) + "</span><span class='red2'>*</span>:</td>"
+ "<td width='35%'><input name='passenger(" + i + ").passengersName' type=\"text\" size=\"20\" eleName='姓名' checkValue='notNull;'/></td>"
+"<td> </td><td> </td></tr>"
+ "</table><br/>");
content += TableContent;
}
content += contentEnd;
document.getElementById("Divtest").innerHTML = content;
}
testTable这个方法是人数选择改变的时候才触发的,跟这个问题没关系吧?