代码如下:
/****************************************************************/
<select name="customer_ranking" id="customer_ranking">
<option label="A" value="A" <?php if($customer_ranking=="A") print "selected"; ?>A</option>
<option label="B" value="B" <?php if($customer_ranking=="B") print "selected"; ?>B</option>
<option label="C" value="C" <?php if($customer_ranking=="C") print "selected"; ?>C</option>
<option label="D" value="D" <?php if($customer_ranking=="D" || strlen($customer_ranking)==0) print "selected"; ?>D</option>
</select>
/*****************************************************************/希望默认是显示D,而打开页面刚开始$customer_ranking也是为空的。
结果页面默认显示是A.
这是为啥啊

解决方案 »

  1.   

    option缺少回标签
    <select name="customer_ranking" id="customer_ranking">
    <option label="A" value="A" <?php if($customer_ranking=="A") print "selected"; ?>>A</option>
    <option label="B" value="B" <?php if($customer_ranking=="B") print "selected"; ?>>B</option>
    <option label="C" value="C" <?php if($customer_ranking=="C") print "selected"; ?>>C</option>
    <option label="D" value="D" <?php if($customer_ranking=="D" || strlen($customer_ranking)==0) print "selected"; ?>>D</option>
    </select>