jQuery - checked radio button depend on value by Norlihazmey Ghazali

http://stackoverflow.com/questions/32325097/select-radiobutton-when-text-equals-value-of-radiobutton

by Norlihazmey Ghazali

HTML

<label>Anrede
    <input type="radio" id="Herr" name="anrede" value="Herr" />Herr
    <input type="radio" id="Frau" name="anrede" value="Frau" />Frau</label>
<select id='select' name="docsApp.options" size="10" multiple="multiple">
    <option id='Herr' value='Herr'>adas</option>
    <option id='Frau' value='Frau'>adas1</option>
</select>

JavaScript

$('select').click(function() 
{
    var selectedName = $('select[name="docsApp.options"] option:selected').text();
    // unchecked all the radio button first
    $('input[name="anrede"]').prop('checked', false);
    // checked only radio with matched value
    $('input[name="anrede"][value="'+$(this).val()+'"]').prop('checked', true);
    // another rest of the code.....
});