I'm trying to add a button to my form that would essentially run some different php code than my regular form submission code, that would, instead of emailing me the form, convert my page into a nice pdf ready to print. I have everything working except that pressing the button is giving me an error.
我想在我的表单中添加一个按钮,它可以运行一些不同于常规表单提交代码的php代码,它可以将我的页面转换成一个漂亮的pdf格式,以便打印。除了按下这个按钮会给我一个错误外,我什么都能做。
Firebug says :
Firebug说:
Here's the code:
这是代码:
<form id="adaugareanunt" name="adaugareanunt" action="mailerPDF.php" method="post">
<table width="535" border="0" cellspacing="2" cellpadding="3">
<tr class="TrDark">
//... more form code
and for the button:
和按钮:
<div style="text-align:right"><img src="images/print-button.png" onClick="chgAction()" width="60px" height="20px"></div>
with the script:
脚本:
<script language="JavaScript" type="text/JavaScript">
function chgAction()
{
document.getElementById["adaugareanunt"].action = "mailerXFDF.php";
document.getElementById["adaugareanunt"].submit();
document.getElementById["adaugareanunt"].action = "mailerPDF.php";
}
</script>
4 个解决方案
#1
2
Adaugareanunt
is an object key:getElementById["adaugareanunt"]
Adaugareanunt是一个对象键:getElementById[" Adaugareanunt "]
"Adaugareanunt"
is a string passed to the getElementById()
method as argument:getElementById('adaugareanunt')
✓
“Adaugareanunt”是一个字符串传递到getElementById()方法作为参数:getElementById✓(“Adaugareanunt”)
#2
8
document.getElementById["adaugareanunt"]
change to
改变
document.getElementById("adaugareanunt")
#3
0
Change the block brackets : []
更改方括号:[]
To
来
The round brackets : ()
圆括号:()
Square brackets means new Array.
方括号表示新数组。
var ar = newArray( " a " , " b " ) ;
var ar = [ " a " , " b " ] ;
#4
0
This works fine
这工作好
<script language="javascript" type="text/javascript">
function chgAction()
{
document.getElementById("adaugareanunt").action ="mailerXFDF.php";
document.getElementById("adaugareanunt").submit();
document.getElementById("adaugareanunt").action ="mailerPDF.php";
}
</script>
#1
2
Adaugareanunt
is an object key:getElementById["adaugareanunt"]
Adaugareanunt是一个对象键:getElementById[" Adaugareanunt "]
"Adaugareanunt"
is a string passed to the getElementById()
method as argument:getElementById('adaugareanunt')
✓
“Adaugareanunt”是一个字符串传递到getElementById()方法作为参数:getElementById✓(“Adaugareanunt”)
#2
8
document.getElementById["adaugareanunt"]
change to
改变
document.getElementById("adaugareanunt")
#3
0
Change the block brackets : []
更改方括号:[]
To
来
The round brackets : ()
圆括号:()
Square brackets means new Array.
方括号表示新数组。
var ar = newArray( " a " , " b " ) ;
var ar = [ " a " , " b " ] ;
#4
0
This works fine
这工作好
<script language="javascript" type="text/javascript">
function chgAction()
{
document.getElementById("adaugareanunt").action ="mailerXFDF.php";
document.getElementById("adaugareanunt").submit();
document.getElementById("adaugareanunt").action ="mailerPDF.php";
}
</script>