2017-03-13 57 views
0

我想從組合框的對象中添加一個新值,而當我像處理其他值時那樣做時,我會收到一條消息,指出它未定義。任何想法如何解決它?我無法從組合框中獲得想要的值

main.js

$(document).ready(function() { 
    //the ip-address will have to change to the ip of the host of the app. 
    //in my case the ip is 192.168.1.68 
    var conn = new WebSocket('ws://localhost:8080'); 
    var chatForm = $(".chatForm"), 
     messageInputField = chatForm.find("#message"), 
     messagesList = $("#container"), //taked the name container to match the name of the css and work with the jquery draggabilly 
     usernameForm = $(".username-setter"), 
     usernameInput = usernameForm.find(".username-input"), 
     comboBox = $(".comboboxvalue"), 
     category = comboBox.find("#indexNr"); 

的index.php

<div class="container"> 
     <div class="row"> 
      <div class="col-md-push-2 col-md-8"> 
       <h2>WorkShoppy Messages Application</h2> 
       <h3>Username: <span class="username label label-primary" ></span></h3> 
       <div class="row" id="set"> 
        <form class="username-setter" action="index.php" method="post"> 
         <div class="form-group"> 
          <label for="">Set username</label> 
          <input type="text" name="name" value="" class="form-control username-input" > 
         </div> 
         <button class="btn btn-primary pull-right" name="button" id="btn" onclick="myFunction()">Set</button> 
        </form> 
       </div> 
       <label for="indexNr">Category</label> 
       <br> 
       <select id="indexNr" id="indexNr" name="indexNr"> 
        <option value="positive" class="comboboxvalue">Positive</option> 
        <option value="negative" class="comboboxvalue">Negative</option> 
       </select> 
      </div> 
     </div> 
</div> 

任何想法如何解決這一問題?

+0

你在這一行中有2個'id'屬性'