Hey there! Sign in to join this conversationNew here? Join for free

Trying to do a loop in javascript

Announcements Posted on
Struggling to get a graduate job in IT and tech? 17-05-2016
Find the answers: Edexcel GCSE maths unofficial mark scheme 05-05-2016
  1. Offline

    I have 5 editable fields for an app, but to execute the code i need to do a check to see if all 5 are filled, if 4 are filled different code to execute is needed

    So anyone know how i can do a loop for a check field 5 = null
    loop back to field 4 and check field 4 = to null (if not equal to 4 run code)
  2. Offline

    I'm not quite sure what logic you're after, your post is a bit confusing TBH. It sounds like you'd be better off using an if/else statement, or a switch, rather than a loop. :erm:
  3. Offline

    (Original post by georgeyboy18)
    ...if 4 are filled different code to execute is needed...
    I hope this is for practical purposes rather than because your execution code can't handle checking to determine the quantity of inputs?

    In any case an if/else would work, but a loop can also work. You'd want to have your inputs labelled with a numerical identifier descending from 5. Something like:

    while ($x>0) {
    if (value-in-input$x != "") {
    // Forward to this $handler[$x]
    } else {


Submit reply


Thanks for posting! You just need to create an account in order to submit the post
  1. this can't be left blank
    that username has been taken, please choose another Forgotten your password?
  2. this can't be left blank
    this email is already registered. Forgotten your password?
  3. this can't be left blank

    6 characters or longer with both numbers and letters is safer

  4. this can't be left empty
    your full birthday is required
  1. Oops, you need to agree to our Ts&Cs to register
  2. Slide to join now Processing…

Updated: June 15, 2012
TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Today on TSR

Edexcel GCSE maths answers

Check the unofficial mark scheme

What date is the EU referendum on?
Useful resources
Quick reply
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.