我正在尝试在此表的单元格中返回一个值(下面提供的代码):
<table id="gpa-calc-table" class="d_g d_gl" summary="List of grade items and their values">
<tbody>
<tr style="visibility:hidden;" class="fgskip">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="gpa_calc_headings">
<th scope="col" class="d_hch d_gl">Course Name</th>
<th scope="col" class="d_hch d_gr" style="padding-left:0.1em;">Class Grade</th>
<th scope="col" class="d_hch d_gr" style="padding-left:0.1em;">Grade Points</th>
<th scope="col" class="d_hch d_gr" style="padding-left:0.1em;">Credit Units</th>
<th scope="col" class="d_hch d_gr" style="padding-left:0.1em;">Total Grade Points</th>
</tr>
<tr class=" d_firstRow">
<th scope="row" class="d_gt d_ich" id="gpa_calc_table_r1t">
<label class="subject1" contenteditable=""><strong>First Class</strong></label>
</th>
<td class="d_gn d_gr d_gt">
<label id="r1_cg" contenteditable="">91%<br></label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r1_gp" contenteditable="">
<script>
function func1() {
var x = document.getElementById('r1_cg');
var a = 49.9%;
var b = 54.9%;
var c = 59.9%;
var d = 64.9%;
var e = 69.9%;
var f = 74.9%;
var g = 79.9%;
var h = 89.9%;
if (x>h) {return 4.2};
if (x>g) {return 4.0};
if (x>f) {return 3.5};
if (x>e) {return 3.0};
if (x>d) {return 2.5};
if (x>c) {return 2.0};
if (x>b) {return 1.5};
if (x>a) {return 1.0};}
</script></label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r1_cu" contenteditable="">0-5</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r1_tgp" contenteditable="">CU*GP<br></label>
</td>
</tr>
<tr class=" d_secondRow">
<th scope="row" class="d_gt d_ich">
<label class="subject2" contenteditable=""><strong>Second Class</strong></label>
</th>
<td class="d_gn d_gr d_gt">
<label id="r2_cg" contenteditable="">0-100%</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r2_gp" contenteditable="">0-4.2</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r2_cu" contenteditable="">0-5</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r2_tgp" contenteditable="">CU*GP</label>
</td>
</tr>
<tr class=" d_thirdRow">
<th scope="row" class="d_gt d_ich">
<label class="subject3" contenteditable=""><strong>Third Class</strong></label>
</th>
<td class="d_gn d_gr d_gt">
<label id="r3_cg" contenteditable="">0-100%</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r3_gp" contenteditable="">0-4.2</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r3_cu" contenteditable="">0-5</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r3_tgp" contenteditable="">CU*GP</label>
</td>
</tr>
<tr class=" d_fourthRow">
<th scope="row" class="d_gt d_ich">
<label class="subject4" contenteditable=""><strong>Fourth Class</strong></label>
</th>
<td class="d_gn d_gr d_gt">
<label id="r4_cg" contenteditable="">0-100%</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r4_gp" contenteditable="">0-4.2</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r4_cu" contenteditable="">0-5</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r4_tgp" contenteditable="">CU*GP</label>
</td>
</tr>
<tr class=" d_fifthRow">
<th scope="row" class="d_gt d_ich">
<label class="subject5" contenteditable=""><strong>Fifth Class</strong></label>
</th>
<td class="d_gn d_gr d_gt">
<label id="r5_cg" contenteditable="">0-100%</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r5_gp" contenteditable="">0-4.2</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r5_cu" contenteditable="">0-5</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r5_tgp" contenteditable="">CU*GP</label>
</td>
</tr>
<tr class=" d_sixthRow">
<th scope="row" class="d_gt d_ich">
<label class="subject6" contenteditable=""><b>Sixth Class</b><br></label>
</th>
<td class="d_gn d_gr d_gt">
<label id="r6_cg" contenteditable="">0-100%</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r6_gp" contenteditable="">0-4.2</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r6_cu" contenteditable="">0-5</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r6_tgp" contenteditable="">CU*GP</label>
</td>
</tr>
</tbody>
</table>
此代码描述了表格中的一行(类似的应用程序将应用于其他行
`<tr class=" d_firstRow">
<th scope="row" class="d_gt d_ich" id="gpa_calc_table_r1t">
<label class="subject1" contenteditable=""><strong>First Class</strong></label>
</th>
<td class="d_gn d_gr d_gt">
<label id="r1_cg" contenteditable="">91%<br></label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r1_gp" contenteditable="">
<script>
function func1(){
var x = document.getElementById('r1_cg');
var a = 49.9%;
var b = 54.9%;
var c = 59.9%;
var d = 64.9%;
var e = 69.9%;
var f = 74.9%;
var g = 79.9%;
var h = 89.9%;
if (x>h) {return 4.2};
if (x>g) {return 4.0};
if (x>f) {return 3.5};
if (x>e) {return 3.0};
if (x>d) {return 2.5};
if (x>c) {return 2.0};
if (x>b) {return 1.5};
if (x>a) {return 1.0};}
</script></label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r1_cu" contenteditable="">0-5</label>
</td>
<td class="d_gn d_gr d_gt">
<label id="r1_tgp" contenteditable="">CU*GP<br></label>
</td>
</tr>`
&lt;脚本&GT;因为如果等级在79.9%和89.9%之间,或者如果等级在59.9%和64.9%之间,那么我试图回报说4.0,等等。注意这是一个GPA计算器可能会有所帮助,我需要if(x> h)优先于链中较低的'if'函数等。任何帮助都表示赞赏。