Reputation: 7
I have an input type text and a button in an asp.net page and I want to add a Listbox to the page. I also want to add the value of the textbox to the Listbox when I click the button
<button id="ajouter" type="button" >Ajouter au panier</button>
<input class="text" id="Num" type="text" name="Num" />
Can someone help me and explain how to define listbox in the page and how to add the text from the textbox to the listbox when the button is clicked.
Upvotes: 0
Views: 150
Reputation: 609
add this code in javascript method
function GetValues() {
.......................
myList.append(''+ Selectedelement +'');
...............
}
Upvotes: 1
Reputation: 609
that's the definition of list and the button :
Ajouter au panier
and now this is the javascript code :
function GetValues() {
debugger;
var myList = $("#multiSelect");
var yy = $("#idtext2").val();
var Selectedelement = $("#idtext").val();
myList.append('<option value=' + Selectedelement + '>' + Selectedelement + " " + yy + '</option>');
global.push({ "id": yy, "qte": Selectedelement });
}
Upvotes: 1
Reputation: 31
If you don't want to remember the data just list it temporary try with jQuery.
Upvotes: 1