0

我想在选择更改事件时加载一个页面。但它不是显示页面。页面上的内容只是:这是银行/这是现金。

<!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>
4

1 回答 1

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>
于 2013-06-23T14:52:46.470 回答