2015-07-10 45 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)"> 
相關問題