EchoFool Posted August 19, 2009 Share Posted August 19, 2009 I have a menu of images i want a user to select then submit that option to update their avatar... currently its not working fulll stop and im getting a strange error... this is the jist of whats going on: var state1 = '#000000'; var state2 = '#FF0000'; function avatar(ava) { var i = 1; for( i < 17 ) { var thiscell = document.getElementById('avatar'+i); if(ava == i) { createplyr.av.value = i; thiscell.style.backgroundColor = state2; }else{ thiscell.style.backgroundColor = state1 ; } i++ } } My current error is this: syntax error [break on this error] for( i < 17; ) { \n This is from firebug in FF, but i can't see my syntax mistake ? What have i done? Quote Link to comment Share on other sites More sharing options...
ldb358 Posted August 19, 2009 Share Posted August 19, 2009 i dont really know for sure but try changing that to a while loop while(i < 17){ //code } Quote Link to comment Share on other sites More sharing options...
EchoFool Posted August 19, 2009 Author Share Posted August 19, 2009 missing ) after condition [break on this error] while( i < 17; ) { \n Different error this time... this is the latest script: function avatar(ava) { var i = 1; while( i < 17; ) { var thiscell = document.getElementById('avatar'+i); if(ava == i) { createplyr.av.value = i; thiscell.style.backgroundColor = state2; }else{ thiscell.style.backgroundColor = state1 ; } i++ } } Quote Link to comment Share on other sites More sharing options...
ldb358 Posted August 19, 2009 Share Posted August 19, 2009 i dont think you need the ";" in the while loop other than that i would think that it would work Quote Link to comment Share on other sites More sharing options...
EchoFool Posted August 20, 2009 Author Share Posted August 20, 2009 fixed thanks guys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.