2

ドロップダウン ボックスの topicList 配列を介して Controller から TopicName を取得し、それをドロップダウンに表示しています。私がやりたいことは、選択したドロップダウンの値に送り返すときに、topicId (topicList 配列にも格納されている) を JavaScript 関数を介してコントローラーに送信することです。これが私のHtmlコードです。トピックを選択:

      <td>
           <select name="Topic" id="Topic" class="myDropDown">
                     <option selected="selected" value="-1">-- Select Topic --</option>

                      <c:forEach var="item" items="${topicList}">
                         <option >${item.topicName} </option>
                       //Here I want to send the value of item.topicId`enter code here`
                       </c:forEach>
            </select>

      </td>

これが私の値を送信することによる私のJavaScript関数です function doAddTopic(){

                         var subName=jq("#Topic option:selected").val();
                        // alert(name);aaaaaaaaaaaaaaaaaaaaaaaaaaaaa

                    var url = "/xyz/abc/"+subName+"/";
                         jq.post(url, function(data) 
                       }

私が欲しいのは、item.topicName の値を送信したい item.topicName を選択することです。どうすればこれを行うことができますか

4

1 に答える 1

1

このように試してみるとよいかもしれません。

<c:forEach var="item" items="${topicList}">
                         <option value="${item.topicId}">${item.topicName} </option>
                       //Here I want to send the value of item.topicId`enter code here`
                       </c:forEach>

オプション内に値を与えるvalue="${item.topicId}"

于 2013-07-20T06:39:05.563 に答える