2015-07-10 49 views
2

我想创建一个页面来初始化要使用的地理定位API。此页面将有两个单选按钮在选项之间切换。我已经创建了两个单选按钮像这样:使用Struts框架在JSP中使用表单输入的单选按钮

<tr> 
    <td colspan="2"> 
     <bean:message key="config.geolocation.page.text"/> 
    </td> 
</tr> 
<tr> 
    <td class="odd" width="20%" nowrap> 
     <bean:message key="editvarref.header.geolocation.pick.api"/> 
    </td> 
    <td class="odd" width="80%"> 
     <div> 
     <html:radio styleId="logo_type_0" property="b_type" value="0" onclick="show_logo(false)" /> 
     <label for="b_type_0"><bean:message key="geolocation.use.google"/></label> 
     </div> 
     <div style="padding-top:5px; padding-bottom:5px;"> 
      <html:radio styleId="b_type_1" property="b_type" value="1" onclick="show_logo(true)" /> 
      <label for="bo_type_1"><bean:message key="geolocation.use.skyhook"/></label> 
     </div> 
    </td> 
</tr> 

如何修改单选按钮,用户可以输入值显示不同的输入字段。我正试图使两个单选按钮显示不同的输入字段。所以当选择一个时,它会显示某些字段,当另一个字段被点击时,它会显示不同的字段。该领域将是一个文本框,用户可以输入信息

+0

你可以阅读谷歌开发者指南。 –

+0

@RomanC这个问题不是关于API,关于单选按钮和输入字段 – 3rdeye7

+0

写一些JavaScript? –

回答

0

SCRIPT

$(document).ready(function() { 
$(".text").hide() 

}); 
function getResults(elem) { 
elem.checked && elem.value == "Show" ? $(".text").show() : $(".text").hide(); 

HTML

<input type="radio" name="radio1" value="Show" onClick="getResults(this)"> 
Do nothing               
<input type="radio" name="radio1" value="Nothing" onclick="getResults(this)"> 
相关问题