Hi
I'm developing my first rails application and would like advice on how
to show a small image in a table cell based on a selection. This will
be based on a user selecting a Risk score from a select or check box
Hi
I'm developing my first rails application and would like advice on how
to show a small image in a table cell based on a selection. This will
be based on a user selecting a Risk score from a select or check box
onchange of a select box you can use remote_function to call an action
and user replace_html or on your rjs file to replace the html to show
the jpg
Thanks for the advice Sami
In case anyone else is trying to do something similar, here is the jquery code I used -
$('div.risk').each(function() {
var value = $.trim($(this).text());
var src;
switch(value) {
case 'Critical':
src = '/images/risk_high.png';
break;
case 'Medium':
src = '/images/risk_med.png';
break;
case 'Low':
src = '/images/risk_low.png';
break;
case 'Information':
src = '/images/risk_info.png';
break;
}
$img = $('<img/>').attr('src', src);
$(this).html($img);
});