0

This is my code and I am not sure why I cant store the value into the data base

The error should be at this line :

document.getElementById('divPrize').innerHTML = prizes[x]['name'];

Code:

// 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;
    }
}
2
  • provide code on jsfiddle Commented Feb 10, 2014 at 6:02
  • Hey, This is the fiddle jsfiddle.net/GPD24 Commented Feb 10, 2014 at 6:18

2 Answers 2

1

Use innerHTML property

 document.getElementById('<%=lblPrize.ClientID %>').innerHTML = prize[x]['name'];

instead of

document.getElementById('<%=lblPrize.ClientID %>').attributes['Text'] = prize[x]['name'];

DEMO

Sign up to request clarification or add additional context in comments.

Comments

0

You can try this ...

document.getElementById('<%=lblPrize.ClientID %>').innerHTML = prize[x]['name'];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.