Select Lists From Dropdown In Jquery
this is my jquery and javascript with this i have a drop down from which i can select files.. so i need is that i have to select multiple files from this dropdown and placed on ne
Solution 1:
As far i understood your question, are you trying to add values
to div once its clicked ?
This may help you.
HTML:
<dl id="sample_dp_1" class="dropdown2"> <dt><a href="#"><span></span></a></dt>
<dd>
<ul>
<li><a href="#">Value Here</a>
</li>
<li><a href="#">Value Here</a>
</li>
<li><a href="#">Value Here</a>
</li>
<li><a href="#">Value Here</a>
</li>
<li><a href="#">Value Here</a>
</li>
<li><a href="#">Value Here</a>
</li>
<li><a href="#">Value Here</a>
</li>
<li><a href="#">Value Here</a>
</li>
</ul>
</dd>
</dl>
<div id="add_dd"></div>
JQuery:
$('#sample_dp_1 li').click(function(){
var data = $('#add_dd').html();
data = data + '<li>'+ $(this).text() + '</li>';
$('#add_dd').html(data);
});
Solution 2:
Ok so the way I understood it is that you want to be able to select items from two dropdowns and add them to another div when you click a button.
Essentially you need to find the selected item of both dropdowns in the click event of the button. So your javascript would be something like:
$('#add_more_btn_id').click(function() {
dd1_selected = $( '#dropdown_1 option:selected' ).val();
dd2_selected = $( '#dropdown_2 option:selected' ).val();
});
where dropdown_1 and dropdown_2 are the id elements of the two dropdowns and add_more_btn_id is the id of the button to add more filters.
To add that dd1_selected and dd2_selected to another div you could do:
$('#add_dd').append("Selected "+dd1_selected+" in DropDown1 and "+dd2_selected+" in DropDown2");
Post a Comment for "Select Lists From Dropdown In Jquery"