I have a dropdown list with multi input choices. Users can pick whatever they like and each time they pick, their choice will show in the field.
Problem:
1. I try to get a value name of an input by var inputName = $('input').attr('name'); , but somehow it does work. Please give a hand on this issue.
- After they pick, if they change their mind and want to delete one or more what they have chosen, how can I create a X button next to a product for deleting?
Thanks!
JF
$(function() {
$('.field-store').click(function(){
$('.dropdown-menu').slideToggle('fast');
})
$('.dropdown-menu input').click(function() {
$('.txt-title').hide();
var inputName = $('input').attr('name');
$('.multi-selects').append('inputName ');
})
})
HTML
<div class="field-store">
<span class="txt-title">Pick what you like</span>
<span class="multi-selects"></span>
</div>
<ul class="dropdown-menu">
<li>
<input type="checkbox" name="cheese">Cheese</input>
</li>
<li>
<input type="checkbox" name="tomatoes">Tomatoes</input>
</li>
<li>
<input type="checkbox" name="mozarella">Mozzarella</input>
</li>
<li>
<input type="checkbox" name="mushrooms">Mushrooms</input>
</li>
<li>
<input type="checkbox" name="pepperoni">Pepperoni</input>
</li>
<li>
<input type="checkbox" name="onions">Onions</input>
</li>
</ul>
CSS
.field-store {
width: 50%;
height: 40px;
background: white;
border: 1px solid black;
}
.dropdown-menu {
display: none;
}