0

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++;
    }
}
3
  • 2
    your code looks good. Where is the html? And what isn't working? Any error in console? Commented Sep 24, 2013 at 7:26
  • 2
    Learn how to debug JavaScript Commented Sep 24, 2013 at 7:27
  • As Sudhir wrote below, it was a syntax error. I should remove the semicolon from while(pcount<20;) to while(pcount<20). Thank you all guys! Commented Sep 24, 2013 at 7:31

2 Answers 2

2

remove the semicolon from while loop, like:

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

to

while(pcount<20){
Sign up to request clarification or add additional context in comments.

Comments

0

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

remove this

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.