1

我网页上的所有链接都没有生成它们的 JavaScript 函数。我运行了 JavaScript 控制台,我得到了所有 JavaScript 函数的 Uncaught ReferenceError。

<div style="text-align:center; margin:5px; ">
<form name="jumpDriver">
  <select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
    <option value=""> - Select a Schedule - </option>
    <?php
    $sql = 'SELECT `description`,`group_id` FROM `t_sched_groups` WHERE `status` > 0 ORDER BY `group_id` DESC';
    $stmnt = $db_transpo->prepare($sql);
    $stmnt->bind_result($description,$groupid);
    $stmnt->execute();
    while ($stmnt->fetch()) {
        if (isset($_GET['groupid']) AND $_GET['groupid'] == $groupid) {
            echo '<option value="?coord=editSignupStruct&amp;groupid=',$groupid,'" selected>',$description,"</option>\n";
        } else {
            echo '<option value="?coord=editSignupStruct&amp;groupid=',$groupid,'">',$description,"</option>\n";
        }
    }
    $stmnt->close();
    ?>
  </select>
</form>

<?php //Show existing structure data, if it exists.
if (isset($_GET['groupid'])) {
$sql = 'SELECT `recurring` FROM `t_sched_groups` WHERE `group_id`=?';
$stmnt = $db_transpo->prepare($sql);
$stmnt->bind_param('i',$_GET['groupid']);
$stmnt->bind_result($recur);
$stmnt->execute();
$stmnt->fetch();
$stmnt->close();

 //Show add day link.
echo '<span id="topthing" style="text-align: center;"><h2><a href="javascript:generateAddDayForm(\'topthing\',',clean($_GET['groupid']), ',',$recur,')">Add Day To Schedule</a></h2></span>';

$sql = 'SELECT `table_id`,`date`,`week` FROM `t_sched_main` WHERE `group_id`=? ORDER BY `date`';
$stmnt = $db_transpo->prepare($sql);
$stmnt->bind_param('i',$_GET['groupid']);
$stmnt->bind_result($tableid,$date,$week);
$stmnt->execute();
$stmnt->store_result();
if ($stmnt->num_rows == 0) {
    echo '<div class="alertText">No structure data yet exists for this schedule.</div>';
    $stmnt->close();
} else {
    //Gather the day information
    $imax=0;
    while ($stmnt->fetch()) {
        $tableids[] = $tableid;
        $dates[] = $date;
        $weeks[] = $week;
        $imax++;
    }
    $stmnt->close();

    //Gather information for each day separately and display.
    $sql = 'SELECT     ts.`structure_id`,tdc.`dc_group_description`,ts.`dc_group_id`,ts.`start`,ts.`end`,ts.`permissions`,ts.`order`,ts.`nodc` FROM `t_sched_structure` as ts,`t_sched_dc_groups` as tdc WHERE ts.`table_id`=? AND tdc.`dc_group_id`=ts.`dc_group_id` ORDER BY ts.`order` ASC';
    $stmnt = $db_transpo->prepare($sql);
    $subi = 0;
    for ($i=0; $i<$imax; $i++) {
        //Open the day-by-day div tag.
        echo '<div style="text-align: center; border:thin solid #000066; background-color:#AAAAFF; padding: 15px; margin: 10px;">',"\n";
        $month = substr($dates[$i],5,2);
        $day = substr($dates[$i],8,2);
        $year = substr($dates[$i],0,4);
        if ($recur) { $date = dateToWeekday($dates[$i]); } else { $date = date("l, M. dS Y", mktime(0,0,0,$month,$day,$year)); }
        echo '<h2>',$date,', Week ',$weeks[$i],' (<a href="javascript:generateWeekChangeForm(\'span',$subi,'\',\'',$tableids[$i],'\',\'',$recur,'\')">Change </a>&nbsp;<a href="javascript:generateDelDayForm(\'',$tableids[$i],'\')">Delete</a>)</h2>',"\n";

        $stmnt->bind_param('i',$tableids[$i]);
        $stmnt->bind_result($structid,$line,$dcid,$start,$end,$perm,$order,$nodc);
        $stmnt->execute();

        if ($stmnt->num_rows == 0) {
            echo '<span id="span',$subi,'"></span>'; //Need an empty span for forms to print to in case of no structure data.
            $subi++;
        }
        while ($stmnt->fetch()) {
            echo '<span style="font-weight: bold;" id="span',$subi,'">',$line,' - Start Time: ',$start,', End Time: ',$end,', Permission: ',permissionCodeToTitle($perm),', No Driver Changes: ',intboolToYesNo($nodc),', Order: ',$order,' <a href="javascript:generateChangeForm(\'span',$subi,'\',\'',$structid,'\',\'',$dcid,'\',\'',$start,'\',\'',$end,'\',\'',$perm,'\',\'',$order,'\',\'',$nodc,'\')">Change</a> <a href="javascript:generateDelForm(\'',$structid,'\')">Delete</a></span><br />',"\n";
            $subi++;
        }

        //Close the div tag and print some day options
        echo '<p><a href="javascript:generateAddForm(\'span',($subi - 1),'\',\'',$tableids[$i],'\')">Add New Line </a>&nbsp;&nbsp;<a href="javascript:generateLoadForm(\'span',($subi - 1),'\',\'',$tableids[$i],'\')">Load From Template </a>&nbsp;&nbsp;<a href="javascript:generateSaveTempForm(\'span',($subi - 1),'\',\'',$tableids[$i],'\')">Save as Template </a></p></div>';
    }
    $stmnt->close();
}

}

我花了很多时间搜索其他帖子,但我无法弄清楚为什么没有一个 JavaScript 运行正确。再次,我得到了错误

Uncaught ReferenceError: generateWeekChangeForm is not defined
Uncaught ReferenceError: generateAddDayForm is not defined
Uncaught ReferenceError: generateDelDayForm is not defined
Uncaught ReferenceError: generateChangeForm is not defined
Uncaught ReferenceError: generateDelForm is not defined
Uncaught ReferenceError: generateAddForm is not defined

如果您需要任何其他代码,请告诉我。谢谢您的帮助。

声明函数 generateAddForm 的代码

    //Function for generating 'add new line' form.
    function generateAddForm(spanid,tableid) {
    if (window.formbool) { //Don't continue, another form exists.
        return;
    } else { //Nothing exists yet, start a new one.
        window.formbool = true;
        var forma = document.createElement('form');
        forma.setAttribute('action','?coord=editSignupStruct&groupid='+190);
        forma.setAttribute('method','POST');
        forma.setAttribute('id','genaddform'+tableid);

        //Create hidden input for tableid
        var hiddeninp = document.createElement('input');
        hiddeninp.setAttribute('type','hidden');
        hiddeninp.setAttribute('name','add_tableid');
        hiddeninp.setAttribute('value',tableid);
        forma.appendChild(hiddeninp);
    }

    //Create input field for line
    var linetext = document.createTextNode('Line: ');
    var lineselect = document.createElement('select');
    lineselect.setAttribute('name','add_line');

    //here are a few of the options that can be chosen

    var option = document.createElement('option');
    var opttext = document.createTextNode('AVS Dispatch');
    option.setAttribute('value','41');
    option.appendChild(opttext);
    lineselect.appendChild(option); 
    var option = document.createElement('option');
    var opttext = document.createTextNode('Bike PM');
    option.setAttribute('value','56');
    option.appendChild(opttext);
    lineselect.appendChild(option); 
    var option = document.createElement('option');
    var opttext = document.createTextNode('Blue 1');
    option.setAttribute('value','5');
    option.appendChild(opttext);
    lineselect.appendChild(option);
//Create input field for start time
    var starttext = document.createTextNode(' Start Time: ');
    var startinp = document.createElement('input');
    startinp.setAttribute('type','text');
    startinp.setAttribute('style','width: 4em');
    startinp.setAttribute('name','add_start');
    forma.appendChild(starttext);
    forma.appendChild(startinp);

    //Create input field for end time
    var endtext = document.createTextNode(' End Time: ');
    var endinp = document.createElement('input');
    endinp.setAttribute('type','text');
    endinp.setAttribute('style','width: 4em');
    endinp.setAttribute('name','add_end');
    forma.appendChild(endtext);
    forma.appendChild(endinp);

//Create input field for permission level
    var permtext = document.createTextNode(' Permission: ');
    var permsel = document.createElement('select');
    permsel.setAttribute('name','add_perm');

    var opt = document.createElement('option');
    var opttext = document.createTextNode('Trainee');
    opt.setAttribute('value','1');
    opt.appendChild(opttext);
    permsel.appendChild(opt);

//Create hidden input for default value
    var hid = document.createElement('input');
    hid.setAttribute('type','hidden');
    hid.setAttribute('name','nodc');
    hid.setAttribute('value','0');
    forma.appendChild(hid);

    //Create input for supression of driver changes
    var inp = document.createElement('input');
    var inptext = document.createTextNode(' No Driver Changes: ');
    inp.setAttribute('type','checkbox');
    inp.setAttribute('name','nodc');
    inp.setAttribute('value','1');
    forma.appendChild(inptext);
    forma.appendChild(inp);

    //Create input field for order
    var ordtext = document.createTextNode(' Order: ');
    var ordinp = document.createElement('input');
    ordinp.setAttribute('type','text');
    ordinp.setAttribute('style','width: 2em');
    ordinp.setAttribute('name','add_order');
    forma.appendChild(ordtext);
    forma.appendChild(ordinp);

    //Create submit button, but only if this is the first creation of this form on this day.
    if (!document.getElementById('genaddform'+tableid)) {
        var submit = document.createElement('input');
        submit.setAttribute('type','submit');
        submit.setAttribute('value','Commit');
        forma.appendChild(submit);
    }
    //Make it so.
        var span = document.getElementById(spanid);
        span.appendChild(forma);
4

0 回答 0