www.webdeveloper.com
Results 1 to 4 of 4

Thread: Simple IF Not validating

  1. #1
    Join Date
    Mar 2012
    Location
    Ghent
    Posts
    22

    Unhappy Simple IF Not validating

    For some reason my code fails to draw when i add this into the code. is anything wrong ? thanks

    Code:
    for (i = 0; i < radios.length+1; i++){
    		if(radios[i].checked){
    			question1 = radios[i].value;
    			}
    		}
    
    		data = [question1,2,2,2,2,2,2];
    		drawGraph();
    interactive and development tutorials | http://blog.notflip.be

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,380

    Question

    Quote Originally Posted by notflip View Post
    For some reason my code fails to draw when i add this into the code. is anything wrong ? thanks

    Code:
    for (i = 0; i < radios.length+1; i++){
    		if(radios[i].checked){
    			question1 = radios[i].value;
    			}
    		}
    
    		data = [question1,2,2,2,2,2,2];
    		drawGraph();
    Lots of things wrong, like where is the rest of the code?
    For example:
    1. What are the values of the radio buttons?
    2. Where is 'question1' defined to receive the value of the radio button?
    3. What does the 'data[]' array represent?
    4. What does 'drawGraph()' do? Especially in relationship to the radio button selection?
    5. Where is 'question1' used in the for...loop?

    So many questions, so little time ...

  3. #3
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by notflip View Post
    Code:
    i < radios.length+1
    What are you expecting to find 2 elements past the end of the array?

    That code must generate errors in the console.
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,380

    Exclamation

    Quote Originally Posted by Logic Ali View Post
    What are you expecting to find 2 elements past the end of the array?

    That code must generate errors in the console.
    #6. That too.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles