我在下面有这个保存功能提交表单,但我希望能够在onclick上添加一个功能来关闭弹出窗口并在表单提交后刷新父目录。
echo '<input type="submit" name="submit" value="'.get_string('savechanges').'"
onclick = "document.getElementById(\'submitform\').menuindex.value = document.getElementById(\'submitform\').grade.selectedIndex." />';
<script type="text/javascript">
function proceed(){
window.opener.location.reload(true);
window.close();
}
</script>
我尝试了一些无济于事的事情。任何帮助将不胜感激。
答案 0 :(得分:0)
HTML:
<div onclick="funcA(); funcB()">Click Me</div>
JavaScript的:
function funcA(){
alert(10);
}
function funcB(){
alert(12)
}
要回答这个问题:使用;
分隔不同的功能。总而言之,您只需在onclick中键入javascript,只需将;
修改强>
<script type="text/javascript">
function proceed(){
window.opener.location.reload(true);
window.close();
}
function inputClick(){
var submitform = document.getElementById(\'submitform\');
submitform.menuindex.value = submitform.grade.selectedIndex;
}
echo '<input type="submit" name="submit" value="'.get_string('savechanges').'"
onclick = "inputClick(); proceed(); return false;" />';
</script>
答案 1 :(得分:0)
如果窗口是跨域的,则由于安全性而无法正常工作。
您是否收到任何错误?
父母是否重新加载?
弹出窗口是否关闭?
Personnaly我会因为弹出窗口拦截器而避免这样做。我找到的最好的方法是使用一个带有iframe的虚假html窗口。
我只使用过这些最新版本的商业版本,这里是一个html窗口的演示链接。 http://aspnetajax.componentart.com/control-specific/dialog/features/core_features/webform1.aspx
我确信有免费的图书馆可以做到这一点。
修改强>
我刚注意到你有一个“;”在行尾缺少
echo '<input type="submit" name="submit" value="'.get_string('savechanges').'"
onclick = "document.getElementById(\'submitform\').menuindex.value = document.getElementById(\'submitform\').grade.selectedIndex;" />';