Simos Sigma
Simos Sigma

Reputation: 978

Javascript while loop failure

Into a php page I have 20 text boxes. I want to make a button, using javascript, and when user clicks on it the rest 19 text boxes to take 1st text box's text. I have done something like this but it isn't working... Any idea?

function Throw_PhotoStuff(){
    var pcount=1; 
    while(pcount<20;){
      document.getElementById('photo_'+pcount).value = document.getElementById('photo_1').value; pcount++;
    }
}

Upvotes: 0

Views: 80

Answers (2)

Gurminder Singh
Gurminder Singh

Reputation: 1755

I think you have extra semicolon here while(pcount<20;){

remove this

Upvotes: 0

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

remove the semicolon from while loop, like:

while(pcount<20;){  //will show SyntaxError: missing ) after condition

to

while(pcount<20){

Upvotes: 2

Related Questions