我想在select on change事件上加载页面。但它不显示页面。页面上的内容只是:这是银行/这是现金。
<!DOCTYPE html>
<html>
<select id = "ddl" onchange="changeSheet()">
<option value = "bank">Bank Statement</option>
<option value = "cash">Cash Book</option>
</select>
<div id = "sheet">
</div>
<script>
function changeSheet()
{
document.getElementById('sheet').innerHTML = "";
var e = document.getElementById("ddl");
var strUser = e.options[e.selectedIndex].value;
if(strUser == 'bank')
{
$("#sheet").load("bank.php");
}
else
{
$("#sheet").load("cash.php");
}
}
</script>
答案 0 :(得分:0)
使用JQuery这是正确的方法: DEMO
<!DOCTYPE html>
<html>
<select id = "ddl" onchange="changeSheet()">
<option value = "bank">Bank Statement</option>
<option value = "cash">Cash Book</option>
</select>
<div id = "sheet"></div>
<script>
$(document).ready(function(){
$("#ddl").change(function(){
if($(this).val() === "bank")
$("#sheet").load("bank.php");
else
$("#sheet").load("cash.php");
});
});
</script>