如何把数据库里某个字段的值映射到JSP页面单按钮上

方法1:

<input type="radio" name="sex" value="A" <%=接收变量.equals("A")?"checked":"" />

 

方法2:

<form name="form1" method="post" action="">

  <p>

  <label>

  <input type="radio" name="sex" value="1">

  a</label>

  <br>

  <label>

  <input type="radio" name="sex" value="2">

  b</label>

  <br>

  <label>

  <input type="radio" name="sex" value="3">

  c</label>

  <br>

  </p>

</form>

 

<script language="javascript" type="text/javascript">

var val = 2;//将被选中的值 在修改页面用程序中取到的值替换

var aa = document.all['sex'];

for(var i=0;i<aa.length;i++){

if(aa[i].value==val){

aa[i].checked =true;

break;

}

}

</script>

 

方法3:

var temp = 你从后台传过来的值

var rad = document.getElementsByName(你的单选按钮);

 

for(var i = 0;i<rad.length;i++)

{

if(rad[i].value == temp)

{

red[i].checked = true;

}

}

 

方法4:

var obj_sex= document.form1.sex;

                                  for(i=0;i<obj_sex.length;i++)

                                      {

                                          if(obj_sex[i].value==sex)

                                          {

                                                 document.form1.sex[i].selected = true;

                                                 changeselect1(sex);

                                          }

                                      }

 

 

 

<select id="t_housetype" style="WIDTH: 85px" name="t_housetype">

                      <option value="">请选择</option>

                      <option value="住宅" <% if rsInfo("t_housetype")="住宅" then response.write"selected='selected'"%>>住宅</option>

                      <option value="写字间" <% if rsInfo("t_housetype")="写字间" then response.write"selected='selected'"%>>写字间</option>

                     <option value="其他" <% if rsInfo("t_housetype")="其他" then response.write"selected='selected'"%>>其他</option>

                  </select>

 

转载于:https://www.cnblogs.com/weicaijin88/archive/2012/04/12/2444209.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值