My javascript code like this :
$(function(){
$('input[type="radio"]').click(function(){
var $radio = $(this);
var name = $(this).prop("name");
// if this was previously checked
if ($radio.data('waschecked') == true)
{
$radio.prop('checked', false);
$radio.data('waschecked', false);
$('#result-select').text('');
}
else{
$radio.data('waschecked', true);
$("input[name=\""+name+"\"]:not(:checked)").data('waschecked', false);
$('#result-select').text(txt);
}
var output = [];
var txt;
$('input[type="radio"]:checked').each( function() {
txt = $(this).parent().text();
output.push(txt);
});
$('#result-select').text(output.join(' - '));
});
});
Demo and full code like this : http://ift.tt/2gRo5s5
I want to :
If I select chelsea, madrid and juve the result like this :
Chelsea - Madrid - Juve
If I select chelsea and madrid the result like this :
Chelsea - Madrid
If I select chelsea, madrid, juve and milan the result like this :
Chelsea - Madrid - Juve - Milan
So if I check radio button, it display the text. If I uncheck radio button, it not display the text. I check combobox, it display the text. If I uncheck combobox, it not display the text
For example the text :
Chelsea - Madrid - Juve - Milan
I uncheck Juve, the result like this :
Chelsea - Madrid - Milan
On the radio button, it works But on the checkbox, I'm still confused
How can I do it?
Update :
The radio button can be unchecked
For example :
If I select chelsea, madrid and juve the result like this :
Chelsea - Madrid - Juve
Then I uncheck madrid, the result like this :
Chelsea - Juve
Aucun commentaire:
Enregistrer un commentaire