0

我正在尝试创建一个下拉菜单,该菜单由我的 RPi 目录的 PHP 列表创建,然后我可以选择一个条目并使用该.load()功能在我的 siteDev.php 页面上显示选定的 HTML 文件内容。
出现的问题是我无法从下拉菜单中传回值以允许我在#results div 中显示内容。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>PHP and JS Notes</title>
        <!-- Style sheets, .dDown needs to be moved. .dDown
        {float: right} -->
        <style type="text/css">
</style>
        <link href="_resources/coverStyle.css" rel="stylesheet" type="text/css"
        />
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <!-- Loading external files via .load, hard coded 3 main files
        udLoad() will be used to select dated files e.g. 'us25082013.html' -->
        <script language="javascript" type="text/javascript">
            function jLoad0() {
                $('#result').load('devUpdates/devInProg.html #container');
            }
        </script>
        <script language="javascript" type="text/javascript">
            function udLoad(sel) {
                var value = sel.value;
                alert(value + ' page selected');
                $('#result').load('devUpdates/'
                value ' #container');
            }
        </script>
        <!-- This PHP loads the directory and lists the files below in
        the form. -->
        <?php if ($handle=o pendir( 'devUpdates')) { while (false !==( $file=r
        eaddir($handle))) { if (($file !="." ) && ($file !=".." )) { $thelist .='<option value="'
        .$file. '">'.$file. '</option>'; } } closedir($handle); } ?>
    </head>

    <body class="welcomeDiv">
        <form>
            <input type="button" name="pin" onclick="jLoad0()" value="Dev In Prog">
        </form>
        <!-- This is where the list of udxxxxxxxx.html files are listed. I want
        to take one of these and run them in a .load function. -->
        </br>
        </br>
        <form>
            <select name="dDown" class="dDown" id="dDown" onchange="udLoad(this.value)">
                <P>
                    <option value="">Select a page</option>
                </p>
                <P>
                    <?=$thelist?>
                </p>
            </select>
            <input type="submit" value="Go">
        </form>
        </br>
        </br>
        <div id="result"></div>
    </body>

</html>
4

1 回答 1

0

更改以下功能。此函数中缺少附加“+”

function udLoad(sel){
    var value = sel.value;
    alert(value + ' page selected');
    $('#result').load('devUpdates/'value' #container');
}

function udLoad(sel){
    var value = sel;
    alert(value + ' page selected');
    $('#result').load('devUpdates/' + value +' #container');
}
于 2013-08-28T05:03:25.637 回答