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

时间:2022-09-08 15:32:40

方法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>