单击"提交"时,代码应显示函数中的值.以下是代码:
<form method="post">
<input type="hidden" name="HDN_FormClicked" value= <?php echo $clicked ?> />
<?php
if($_POST){
$clicked= "You have clicked the button";}
?>
<input class="button" type="submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)
我是否需要使用$ _get来使代码工作?
<?php
if(isset($_POST['submit_button']))
$clicked = 'You have clicked the button';
?>
<form method="post">
<input type="hidden" name="HDN_FormClicked" value="<?php echo (isset($clicked)) ? $clicked : '' ?>" />
<input class="button" name="submit_button" type="submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)
替代
<?php
$clicked = '';
if(isset($_POST['submit_button']))
$clicked = 'You have clicked the button';
?>
<form method="post">
<input type="hidden" name="HDN_FormClicked" value="<?= $clicked?>" />
<input class="button" name="submit_button" type="submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
60248 次 |
| 最近记录: |