在弹出窗口中提交带有图像的表单

时间:2014-11-26 22:34:56

标签: javascript html forms popupwindow

这是我的代码:

<form id="email" action="email_send.php" method="POST" onsubmit="target_popup(this)">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>">
<input type="text" name="slastupdate" value="<?php echo $row['slastupdate']; ?>" />
<input type="text" name="saldo" size="25" value="<?php echo $row['saldo']; ?>" />

<!--This part of the code gets the form submitted by clicking on an image--!>
<a href="javascript:{}" onclick="document.getElementById('email').submit(); return false;" target="_blank">
<img src="../img/enviar-mail.png"></a>
</form>

我已将此定位于身体的末尾

<script type="text/javascript">
    function target_popup(form) {
        window.open('', 'formpopup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');
        form.target = 'formpopup';
    }
</script>

所以,基本上,这可以通过点击图像来提交表单,并且保持这种方式非常棒。但是target_popup(this)代码应该在提交表单后打开一个弹出窗口,而是将表单发送到同一个窗口。 抱歉英语不好(希望错误),我不是本地人,我可能犯了一些错误:P

1 个答案:

答案 0 :(得分:1)

您应该使用 _blank 作为窗口名称....请替换此行:

window.open('', 'formpopup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');

这一行:

 window.open('', '_blank', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');
相关问题