0

我有一个用 php-pear 创建的表,以及一个处理单击事件以将单元格信息提交到新表单页面的 jquery 函数。jquery是这样的:

    var row = $this.parent('tr').contents('th:eq(0)').html();
    var departmentID = $(".deptSelect").val();  
    var headerObj = $(this).parents('.main').find('th').eq(colIndex);
    var toPass =   $.trim(headerObj.text());
    var picked = $("#picked").val();
    var testDate = new Date(picked + " " + row);
    var today = new Date();

    if (testDate < today)
    {
        if (roleID > 2)
        {
        alert("You Cannot Schedule a New Job in the Past!");
        }
        return;
    }
    var thisForm = '';

    if (roleID == 5)
    {
        thisForm = '../forms/tentativeJobForm.php';
    }
    else
    {
        thisForm ='../forms/newJobForm.php';
    }

    var f = document.createElement("form");
    f.setAttribute('class','jobTime');
    f.setAttribute('method','post');
    f.setAttribute('action',thisForm);

    var iii = document.createElement('input');
    iii.setAttribute('type','hidden');
    iii.setAttribute('name','departmentID');
    iii.setAttribute('value',departmentID);
    f.appendChild(iii);

    var i = document.createElement('input');
    i.setAttribute('type','hidden');
    i.setAttribute('name','sTime');
    i.setAttribute('value',picked + " " + row);
    f.appendChild(i);

    var ii = document.createElement('input');
    ii.setAttribute('type','hidden');
    ii.setAttribute('name','ast');
    ii.setAttribute('value',toPass);
    f.appendChild(ii);

    document.getElementsByTagName('body')[0].appendChild(f);
    if (roleID > 2)
    $('.jobTime').submit;
    else
    return;
});

这在本质上是有效的,但是我的用户抱怨在他们安排新工作时看不到日历页面,并且它与已经安排的另一个工作冲突。我的新要求是生成的冲突页面作为弹出窗口打开。不是存在冲突的警报,而是具有冲突信息的原始表单。上面的表单提交到我的php页面,下面的函数处理冲突:

function checkRows($stmt, $msg=NULL, $params=NULL)//, $updatedInfo=NULL)
{
    if ($stmt != NULL)
    {
        $rows_affected = sqlsrv_rows_affected($stmt);
        if ($rows_affected > 0)
        {
            $starting = new DateTime($params[5]);
            $ending = new DateTime($params[6]);
            $starting = date_format($starting,'m/d/Y h:i a');
            $ending = date_format($ending,'m/d/Y h:i a');

            echo "Job:" . $params[0] . " was Successfully Scheduled for $starting to $ending<br>";
        }
    }
    else
    {
        $userSTime = new DateTime($params[0]);
        $userSTime = date_format($userSTime,'m/d/Y h:i a');

        $userETime = new DateTime($params[1]);
        $userETime = date_format($userETime,'m/d/Y h:i a');     
        $_SESSION['jbNum'] = $params[2];
        $_SESSION['asset'] = $params[4];
        $_SESSION['userSTime'] = $userSTime;
        $_SESSION['userETime'] = $userETime;
        $_SESSION['userDesc'] = trim($params[3]);
        $_SESSION['conJbNum'] = $msg['JobNum'];
        $_SESSION['conSTime'] = date_format($msg['StartTime'], 'm/d/Y h:i a');
        $_SESSION['conETime'] = date_format($msg['EndTime'], 'm/d/Y h:i a');
        $_SESSION['dueDate'] = $params[5];
        $_SESSION['comment'] = $params[6];
        $_SESSION['destination'] = $params[7];
        $_SESSION['jStat'] = $params[8];

        if ($_SESSION['recurring'] == 'n')
        {
        echo "<meta http-equiv='refresh' content='0;URL=../forms/newJobForm.php' target = 'mainFrame'/>";
        exit;
        }
        else
        {
            echo "Scheduling for Job:" . $params[2] ." failed for $userSTime to $userETime<br>";
        }
    }

}

当遇到冲突时,原始表单将使用来自会话变量的新信息打开。如何在弹出窗口中打开表单?我知道这应该不会太难,但我无法让它发挥作用。仅供参考 target='_blank' 已被建议但仅打开一个新选项卡。那是行不通的。

4

2 回答 2

0

您是否在寻找类似对话框的东西?如果是这样,您可以使用 jQueryUI 的 .dialog() 功能。

http://jqueryui.com/dialog/

于 2013-10-23T18:38:09.303 回答
0

在 checkRows 函数中,我必须更改:

echo "<meta http-equiv='refresh' content='0;URL=../forms/newJobForm.php' target = 'mainFrame'/>";
exit;

至:

    echo "<meta http-equiv='refresh' content='0;URL=../pages/schedule.php' target = 'mainFrame'/>";
    echo '<script>window.open("../forms/newJobForm.php",null,"height=550,width=900,status=yes, scrollbars=1, toolbar=no,menubar=no,location=no");</script>';
    echo "<script>window.close()</script>";
于 2013-10-23T19:52:16.677 回答