i would like to know how to create a hidden type input box and labels using javascript by onclick function.
$().ready(function() {
$("#product").autocomplete("get_completeproducts", {
width: 406,
matchContains: true,
selectFirst: false
});
});
<input type="text" value="" name="product" id="product" size="50">
<input type="button" value="Add to List" onclick="addprotolist()" name="select_pro">
i am getting the above input box value through ajax auto complete , the user will click on the select box , then what i have to do is , i have to add list them the number of selected phones bellow the input box like
<label>Samsung Galaxy Y<label><input type="hidden" value="778" name="pro_id[]">
<label>Samsung Galaxy Y Duos<label><input type="hidden" value="788" name="pro_id[]">
<label>Samsung Galaxy Y Plus<label><input type="hidden" value="728" name="pro_id[]">
.
.
.
<input type="submit" name="save" value="Save your list">
anybody can provide me how to code this using javascript or jquery.
Note
If you want to append multiple
input,labeletc using loop, don’t call append within loop, it will slow down performance. Make a string like above and call.append()at last out of loop.For example
But this way it does not really make sense to use a
label. You have to connect it to yourinputeither by wrapping it or by specifying aforattribute pointing to the input’sid:from
labelon MDN