如何在单个提交输入类型上执行colorbox和submit动作


How to perform both colorbox and submit action on single submit input type?

我想执行colorbox和php插入函数在单次点击表单提交。

这是我的表单:

 <form name="album" id="album"  action="#">
       <table>
           <tr>
               <td>Album Name</td>
               <td><input type="text" value="" name="album_titlee" required></td>
           </tr>
           <tr>
              <td colspan="2"><input class="button_new" type="submit" name="submit_album" id="submit_album"  value="ADD"></td>
           </tr>
      </table>
</form>

这是我的colorbox编码

<div style='display:none'>
        <div id='inline_content' style='padding:10px; background:#fff;'>
            <p>We recommend the following resolutions for different print sizes.</p>
            <table>
                   <tbody>
                       <tr>
                          <th width="80" height="25">Size</th>
                          <th>Minimum Resolution</th>
                        </tr>
                        <tr>
                           <td height="25">3.5" x 5"</td>
                           <td>525 x 750 pixels (0.4 megapixels)</td>
                        </tr>
                   </tbody>
            </table>
        </div>
    </div>
</div>

这是我的php函数[For Form Submit]:

<?php
if(isset($_REQUEST['submit_album']))
{
$album_titlee=$_REQUEST['album_titlee'];
$user_id=$_SESSION['ses_userid'];

$sql=mysqli_query($conn,"INSERT INTO tbl_album(user_id,album_title,album_status) VALUES ('".$user_id."','$album_titlee','Y')");
echo("<script type='text/javascript'>$.colorbox({inline:true,width:'50%', href:'#inline_content'});</script>");
}
?>

上面的php代码只是完美地插入数据,但在插入语句之后,我需要在colorbox上打开#inline_content分区。它不会执行。

需要使用ajax。Javascript:

albumTitleeFromInput = $("input[name=album_titlee]").val();
$.ajax({
        url: "/urlToYourPhpScript",
        type: "POST",
        dataType: 'json',
        data: {
            album_titlee: albumTitleeFromInput
        },
        success: function (data) {
            //Open your colorbox in there
        }
    });

我终于实现了我的愿望。只需在表单数据插入后调用java脚本函数。

echo "<script type='text/javascript'>window.onload = function()
{
    popup();
}
</script>";