2013-07-20 59 views
1

我正在抓取TopicName从控制器通过我的下拉框中的topicList数组并将其显示为下拉框。我想要做的是当发送回选定的下拉列表的值我想发送topicId(这也是存储在topicList数组)到我的控制器throgh JavaScript函数。 这是我的Html代码。 选择主题:将所选下拉列表的Dynmic值发送到控制器

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

这里通过IM我的JavaScript函数发送我的价值观 功能doAddTopic(){

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

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

我要的是在选择item.topicName我要发送的值item.topicId。我如何能做到这一点

回答

0

可能是你应该尝试这样的,

<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}"

+0

由于其工作中 –

相关问题