
我用的是form表单属性style颜色赋值, 把text文本框颜色值付给style。

代码如下:
<body >
<?php $color=ffffff?>
<?php
if($_POST[sub]){
$color=$_POST[text];
}
?>
<form name="form" method="post" action="" enctype="" style="background:#<?php echo $color;?>">
<table align="center" width="500" height="500" cellpadding="2" cellspacing="0" >
<tr>
<td align="center" width="500" height="450" bgcolor="" >
<input name="text" type="text" size="20" />
<input name="sub" type="submit" value="提取" />
</td>
</tr>
</table>
</form>
</body>
本文介绍了一种使用PHP和HTML表单来动态改变页面背景颜色的方法。通过将用户输入的颜色值赋给form表单的style属性,实现文本框颜色值的实时应用。此方法适用于需要用户自定义界面颜色的场景。
1636

被折叠的 条评论
为什么被折叠?



