<div id="score_here">10</div>
当我从下拉列表中选择一个值时,我想替换我的内容<select id="ansRate" onchange="javascript:add_score(this);">
。我已经设置了如下所示的 JavaScript 函数,但它不起作用。这有什么问题?
<div>
<select id="ansRate" onchange="javascript:add_score(this);">
<option value="0">Answer Rate</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>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
</div>
<div id="score_here" style="width:100px;height:100px;background-color:yellow;">
81
</div>
<script type="text/javascript">
function add_score(a){
var string = $("#questionScore").text();
var thenum = string.replace( /^\D+/g, '');
var add = $(a).val();
var total = parseInt(thenum) + parseInt(add);
document.getElementByID('score_here').innerHTML = total;
}
</script>