简体   繁体   English

提交表格弹出

[英]submit a form to popup

I have a table created with php-pear, and a jquery function that handles a click event to submit the cell information to a new form page. 我有一个用php-pear创建的表,还有一个处理点击事件的单元格jQuery函数,以将单元格信息提交到新的表单页面。 The jquery is this: 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;
});

This works in essence, but my users have complained about not seeing the calendar page when they schedule new jobs and it conflicts with another job already scheduled. 这本质上是可行的,但是我的用户抱怨他们在计划新作业时看不到日历页面,并且与已经安排的另一个作业发生冲突。 My new requirement is that the resulting conflict page opens as a popup window. 我的新要求是,生成的冲突页面将作为弹出窗口打开。 Not an alert that there was a conflict, but the original form with the conflicting information. 不是警告存在冲突,而是带有冲突信息的原始表单。 The above form is submitted to my php page, and the following function handles conflicts: 上面的表单已提交到我的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>";
        }
    }

}

When a conflict is encountered the original form is opened up with the new information from the session variables. 遇到冲突时,将使用会话变量中的新信息打开原始表单。 How can I open the form in a popup window? 如何在弹出窗口中打开表单? I know this shouldn't be too difficult but I cannot get it to work. 我知道这应该不太困难,但我无法使其正常工作。 FYI target='_blank' has been suggested but only opens a new tab. 建议使用FYI target ='_ blank',但只会打开一个新标签。 That won't work. 那行不通。

Are you looking for something like a dialog box? 您是否正在寻找类似对话框的内容? If so, you can use jQueryUI's .dialog() feature. 如果是这样,则可以使用jQueryUI的.dialog()功能。

http://jqueryui.com/dialog/ http://jqueryui.com/dialog/

In the checkRows function I had to change: 在checkRows函数中,我必须更改:

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

To: 至:

    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>";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM