2017-03-13 2 views
0

Ich möchte einen neuen Wert in einem Objekt aus einer Combobox hinzufügen und während ich es mache wie ich mit den anderen Werten habe ich eine Nachricht, dass es nicht definiert ist. irgendwelche Ideen, wie man es repariert?Ich kann nicht den gewünschten Wert aus einer Combobox

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> 

irgendwelche Ideen, wie dieses Problem beheben?

+0

Sie haben 2 ID-Attribute in dieser Zeile '