php selectradio和checkbox默认选择的实现方法详解

时间:2022-08-29 10:08:44

这是扩展yibing的select默认选择的实现方法

复制代码 代码如下:


<select name="wuyeleixing" size="1">
<option <?php if($myrow[wuyeleixing]==1) echo("selected");?> value="1">住宅</option>
<option <?php if($myrow[wuyeleixing]==2) echo("selected");?> value="2">办公室</option>
<option <?php if($myrow[wuyeleixing]==3) echo("selected");?> value="3">营业房</option>
<option <?php if($myrow[wuyeleixing]==4) echo("selected");?> value="4">厂房</option>
<option <?php if($myrow[wuyeleixing]==5) echo("selected");?> value="5">仓库</option>
<option <?php if($myrow[wuyeleixing]==6) echo("selected");?> value="6">地块</option>
<option <?php if($myrow[wuyeleixing]==7) echo("selected");?> value="7">综合楼</option>
<option <?php if($myrow[wuyeleixing]==8) echo("selected");?> value="8">农牧场</option>
<option <?php if($myrow[wuyeleixing]==9) echo("selected");?> value="9">商住楼</option>
<option <?php if($myrow[wuyeleixing]==10) echo("selected");?> value="10">宾馆酒楼</option>
<option <?php if($myrow[wuyeleixing]==11) echo("selected");?> value="11">校舍</option>
</select>


radio单选框的默认选择实现

复制代码 代码如下:


<input type="radio" name="dishu" value="3" <?php if($myrow[dishu]==3) echo("checked");?>>空白
<input type="radio" name="dishu" value="1" <?php if($myrow[dishu]==1) echo("checked");?>>出让
<input type="radio" name="dishu" value="2" <?php if($myrow[dishu]==2) echo("checked");?>>划拨
<input type="radio" name="dishu" value="4" <?php if($myrow[dishu]==4) echo("checked");?>>集体


checkbox 复选框的默认选择实现

复制代码 代码如下:


<input name="fujia_jiaju" type="checkbox" value="jiaju" <?php if($myrow[fujia_jiaju]) echo("checked");?>></font></strong>家 具</td>
<td width="108" height="1"><strong><font color="#008080" face="楷体_GB2312"><input
name="fujia_chuju" type="checkbox" value="chuju" <?php if($myrow[fujia_chuju]) echo("checked");?>></font></strong>厨 具</td>
<td width="96" height="1"><strong><font color="#008080" face="楷体_GB2312"><input
name="fujia_woju" type="checkbox" value="woju" <?php if($myrow[fujia_woju]) echo("checked");?>></font></strong>卧 具</td>
<td width="99" height="1"><strong><font color="#008080" face="楷体_GB2312"><input
name="fujia_TV" type="checkbox" value="TV" <?php if($myrow[fujia_TV]) echo("checked");?>></font></strong>电视机