这是我的代码,我不知道为什么我不能将值存储到数据库
错误应该在这一行:
document.getElementById('divPrize').innerHTML = prizes[x]['name'];
代码:
// Now we can work out the prize won by seeing what prize segment startAngle and endAngle the relativeAngle is between.
for (x = 0; x < (prizes.length); x ++)
{
if ((relativeAngle >= prizes[x]['startAngle']) && (relativeAngle <= prizes[x]['endAngle']))
{
// Do something with the knowlege. For this example the user is just alerted, but you could play a sound,
// change the innerHTML of a div to indicate the prize etc - up to you.
// store db
document.getElementById('divPrize').innerHTML = prizes[x]['name'];
document.getElementById('<%=lblPrize.ClientID %>').attributes['Text'] = prize[x]['name'];
alert("You won " + prizes[x]['name'] + "!\nClick 'Play Again' to have another go.");
break;
}
}
答案 0 :(得分:1)
使用innerHTML
属性
document.getElementById('<%=lblPrize.ClientID %>').innerHTML = prize[x]['name'];
而不是
document.getElementById('<%=lblPrize.ClientID %>').attributes['Text'] = prize[x]['name'];
答案 1 :(得分:0)
你可以试试这个......
document.getElementById('<%=lblPrize.ClientID %>').innerHTML = prize[x]['name'];