document.getElementById('text').innerHTML += "<td class='surveyquest'>5. Years of Services :</td></tr>";
document.getElementById('text').innerHTML +=
"<tr>
<td>
<select name='services" + fields + "' title='Years of Services'>
var myDate = new Date();
var year = myDate.getFullYear();
for(var i = 2008; i < year+1; i++)
{
document.write('<option value=\"'+i+'\">'+i+'</option>');
}
</select>
</td>
</tr>";
问题是选择框出现如下:
我怎么解决这个问题?
最佳答案
document.getElementById('text').innerHTML += "<td class='surveyquest'>5. Years of Services :</td></tr>";
var myDate = new Date();
var year = myDate.getFullYear() + 1;
var html = '';
for(var i = 2008; i < year; i++)
html += '<option value="' + i + '">' + i + '</option>';
document.getElementById('text').innerHTML += "<tr><td><select name='services" + fields + "' title='Years of Services'>" + html + "</select></td></tr>";
关于javascript - JavaScript年值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17986655/