Reputation: 721
I have input type text, when it clicked dropdown will be show. i've used a plugin from http://labs.abeautifulsite.net/jquery-dropdown/ to show dropdown with data-dropdown . this my code :
<tr>
<td style="width:100px; padding-bottom:12px;">Category</td>
<td>
<input type="text" name="product" placeholder="Select category" maxlength="85" class="full text" data-dropdown="#dropdown-5"/>
<span aria-hidden="true" class="icon-heart line-icon icon-2"></span>
<div id="dropdown-5" class="dropdown dropdown-tip dropdown-anchor-right">
<ul class="dropdown-menu" id="dcategory">
<li>Add Product</li>
<li>Add Category</li>
<li>Add Brand Information</li>
<li>Add Note</li>
</ul>
</div>
</td>
</tr>
i want to get a value from dropdown when it clicked and put it into input ??
is it possible ???
Upvotes: 0
Views: 931
Reputation: 125
Of course it's possible !
Try this with jQuery :
$("ul.dropdown-menu li").click(function(){
this = $(this);
inputval = this.text(); // sorry here it's text
$("input.full").val(inputval);
})
Upvotes: 1
Reputation: 3688
Try this;
$('#dcategory li').click(function(){
var x = $(this).text();
$('input').val(x); //Give proper class
})
Upvotes: 1