My javascript code like this :
$(function(){
$(\'input[type=\"radio\"]\').click(function(){
var txt = $(this).parent().text();
var $radio
You need to first get the text value of the result : var str = $('#result-select').text();
, then when you check a radio button, you just append the value to the result text str += txt; $('#result-select').text(str);
.
And if you uncheck a radio button, you just replace it's value with an empty string str = str.replace(txt,'');
.
$(function(){
$('input[type="radio"]').click(function(){
var txt = $(this).parent().text();
var $radio = $(this);
// if this was previously checked
if ($radio.data('waschecked') == true)
{
$radio.prop('checked', false);
$radio.data('waschecked', false);
var str = $('#result-select').text();
str = str.replace(txt,'');
$('#result-select').text(str);
}
else{
$radio.data('waschecked', true);
var str = $('#result-select').text();
str += txt;
$('#result-select').text(str);
}
// remove was checked from other radios
$radio.siblings('input[type="radio"]').data('waschecked', false);
});
});