而不是重复自己的形式:
<form name="addBlockList" action="" method="post">
Välj blockeringsgrad:
<select name="blockeringsgrad" style="font-size: 12px;">
<option value="1">1 - Bilder</option>
<option value="2">2 - Bilder, Vän, Vägginlägg, PM</option>
<option value="3">3 - Ingen tillgång till profil</option>
</select>
<input type="hidden" name="uID" value="$id">
<br>
<input type="submit" value="Lägg till">
</form>
Run Code Online (Sandbox Code Playgroud)
我想调用一个函数,然后它会显示这个表单.你能这样做吗?对于uID,我可以为函数设置参数吗?
<?php
function showForm($uid){
?>
<form name="addBlockList" action="" method="post">
Välj blockeringsgrad:
<select name="blockeringsgrad" style="font-size: 12px;">
<option value="1">1 - Bilder</option>
<option value="2">2 - Bilder, Vän, Vägginlägg, PM</option>
<option value="3">3 - Ingen tillgång till profil</option>
</select>
<input type="hidden" name="uID" value="<?=$uid?>">
<br>
<input type="submit" value="Lägg till">
</form>
<?php
}
Run Code Online (Sandbox Code Playgroud)
编辑:
如果您希望此方法返回表单,您可以使用输出缓冲,如下所示:
<?php
function showForm($uid){
ob_start();
?>
<form name="addBlockList" action="" method="post">
Välj blockeringsgrad:
<select name="blockeringsgrad" style="font-size: 12px;">
<option value="1">1 - Bilder</option>
<option value="2">2 - Bilder, Vän, Vägginlägg, PM</option>
<option value="3">3 - Ingen tillgång till profil</option>
</select>
<input type="hidden" name="uID" value="<?=$uid?>">
<br>
<input type="submit" value="Lägg till">
</form>
<?php
return ob_get_clean();
}
Run Code Online (Sandbox Code Playgroud)