2013-09-24 52 views
0

进入一个php页面我有20个文本框。我想用javascript制作一个按钮,当用户点击它时,其余的19个文本框将采用第一个文本框的文本。我做了这样的事情,但它不工作......任何想法?Javascript while while循环失败

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

你的代码看起来不错。 html在哪里?什么不工作?控制台中有任何错误? – MaVRoSCy

+2

[学习如何**调试** JavaScript](http://www.netmagazine.com/tutorials/javascript-debugging-beginners) –

+0

Sudhir在下面写道,这是一个语法错误。我应该将while(pcount <20;)'分号从'(pcount <20)'分号中删除。谢谢大家! –

回答

2

从while循环,就像删除分号:

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

while(pcount<20){ 
+0

非常感谢我的朋友! –

+0

不客气.. :) –

0

我觉得你在这里 ,而有额外的分号(pcount < 20;){

删除此内容

+0

是的,你是对的!非常感谢您的宝贵时间! –