Trying to do a loop in javascript
From C++ to PHP, debugging to webhosting; help and discussion about writing your latest program to running your website. NOT for help when your PC won't work.
| Announcements | Posted on | |
|---|---|---|
| TSR launches Learn Together! - Our new subscription to help improve your learning | 16-05-2013 | |
-
Trying to do a loop in javascript
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) -
Re: Trying to do a loop in javascriptI hope this is for practical purposes rather than because your execution code can't handle checking to determine the quantity of inputs?(Original post by georgeyboy18)
...if 4 are filled different code to execute is needed...
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:
Code:$x=5; while ($x>0) { if (value-in-input$x != "") { // Forward to this $handler[$x] } else { $x--; } }