如何在使用jsp和javascript点击相应的表行单选按钮时获取selectbox值?

时间:2017-02-07 05:44:59

标签: javascript jquery html jsp

如何在使用javascript点击相应的表行单选按钮时获取selectbox值?

我有n个单选按钮,当其中一个被选中时我想自动获取相应行选择框值toyname到文本框toynamelpd

这是我的jsp代码

<input type="text" value="" name="toynamelpd" id="toynamelpd"> //here i want to display corresponding selected radio buttons select box value

<table class="table table-condensed table-striped table-bordered" style="width: 100%;" ng-if="lessonPlanDailys.length > 0">
    <thead style="height: 60px; overflow: auto;">
    <tr>
    <th style="text-align: center;color: teal;width: 5%;padding: 1%;"></th>
    <th style="text-align: center;color: teal;width: 5%;padding: 1%;">#</th>
    <th style="color: teal;width: 15%;text-align: center;padding: 1%;">Toys</th>
    </tr>
    </thead>
<tbody>
    <%
    int index = 1;
    for (Map<String, Object> eachtoyPlanDaily : toyPlanDailys) 
    {
    %>
    <tr>
    <td style="text-align: center;width: 5%; "><input type="radio" id="toyPlanId" name="toyPlanId" value="<%=eachtoyPlanDaily.get("_id").toString()%>" onchange="selecttpd()"></td>
    <td style="text-align: center;width: 5%; "><%=index++%></td>
    <td style="width: 15%;text-align: justify; ">
        <select name="toynamelp" id="toynamelp" value="this.value">
        <option value="select">-------------select-------------</option>
        <%
        Iterator iterator = toynameList.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry mapEntry = (Map.Entry) iterator.next();
            if(eachtoyPlanDaily.get("toyname") != null && eachtoyPlanDaily.get("toyname").equals(mapEntry.getValue())){
            %>
                <option selected value="<%=mapEntry.getKey()%>"><%=mapEntry.getValue()%></option>
            <%
            }
            else {
            %>
                <option value="<%=mapEntry.getKey()%>"><%=mapEntry.getValue()%></option>
            <% 
            }
        }
        %>
    </select>
    </td>
    </tr>
   <%
   }
   %>
</tbody>
</table>

我是jsp servlet中的新手,如果你知道,请帮助我

0 个答案:

没有答案