我正在尝试即时更改表单操作,但认为我遇到了语法问题,我只是无法弄清楚。
这有效:
<?php
echo "<input type='submit' id='answerbutton' name='$buttonname'
value='$buttonvalue' onclick='"this.form.action='linktogoto.php''">";
?>
这不起作用:
<?php
$variable = "linktogoto.php";
echo "<input type='submit' id='answerbutton' name='$buttonname'
value='$buttonvalue' onclick='"this.form.action=$variable'">";
?>
我最终需要根据情况改变$variable,所以需要让它工作。
<?php
$variable = "linktogoto.php";
echo "<input type='submit' id='answerbutton' name='$buttonname'
value='$buttonvalue' onclick='"this.form.action=$variable'">";
?>
应该是:
<?php
$variable = "linktogoto.php";
echo "<input type='submit' id='answerbutton' name='$buttonname'
value='$buttonvalue' onclick='"this.form.action='$variable''">";
?>
请注意$variable
周围的'
。