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? Link to comment https://forums.phpfreaks.com/topic/171057-solved-need-help-here-bit-of-a-noob/ 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 } Link to comment https://forums.phpfreaks.com/topic/171057-solved-need-help-here-bit-of-a-noob/#findComment-902165 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++ } } Link to comment https://forums.phpfreaks.com/topic/171057-solved-need-help-here-bit-of-a-noob/#findComment-902172 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 Link to comment https://forums.phpfreaks.com/topic/171057-solved-need-help-here-bit-of-a-noob/#findComment-902173 Share on other sites More sharing options...
EchoFool Posted August 20, 2009 Author Share Posted August 20, 2009 fixed thanks guys Link to comment https://forums.phpfreaks.com/topic/171057-solved-need-help-here-bit-of-a-noob/#findComment-902842 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.