我有一个从数据库动态创建的表
我正在尝试总结字段中的值 I并立即将其显示在select
字段中。own evaluation
value next to it in the same row
Gap
我用来填充这三列的代码是:
echo "<td class='evaluation'>";
echo "<select class='ownlevelselect' id='ownlevelselect' name='level-".$compi['Competence_ID']."' >";
echo "<option value=''>--</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option>";
echo "</select>";
echo '<a target="_blank" href="'.INDEX.'?categ='.$_GET['categ'].'&action='.$_GET['action'].'&subaction=viewlevels'.'&levels='.$compi['Competence_ID'].'">';
echo '<img class="linkki" src="'.KUVAT.'paivita.gif" alt="'._("tiedot").'" title="'._("What is this?").'"/></a>';
echo "</td>";
echo "<td class='mefly'>";
echo $compi['actual_level'];
echo "</td>";
echo "<td class='gap'>";
echo "<input type='text' readonly style='width:20px;'>";
echo "</td>";
我按照建议尝试了这个 Jquery 代码silkfire
,但没有任何改变..
$(function() {
$(document).on('change', 'td.evaluation select', function() {
var gap = $(this).val() + $(this).parent('tr').find('td.mefly').text();
$(this).parent('tr').find('td.gap input:text').val(gap);
});
});
</script>