Forum : whts error in this program its not working
Brief description  about Online courses   join in Online courses
View sriaruna  chandrasekaran 's Profile

whts error in this program its not working

<script type="text/javascript">
function show(){
val = new Array(10)
for(i=0; i<10; i ){
val[i]=i
}
for(i=0; i<10; i ){
document.frm1.txt[i].value=val[i]
}
}

<form name="frm" ><br />
<br />
<input name="txt1" type="text" />
<input name="txt2" type="text" id="txt2" />
<input name="txt3" type="text" id="txt3" />
<input name="txt4" type="text" id="txt4" />
<input name="txt5" type="text" id="txt5" />
<p>

<input name="txt6" type="text" id="txt6" />
<input name="txt7" type="text" id="txt7" />
<input name="txt8" type="text" id="txt8" />
<input name="txt9 " type="text" id="txt9 " />
<input name="txt10" type="text" id="txt10" />
<input type="submit" name="Submit" value="Show the values" onclick="show()" /></p>
</form>
Asked by sriaruna chandrasekaran | Jun 1, 2010 |  Reply now
Replies (2)
View sriaruna chandrasekaran 's Profile
thank u ! can u give any sample or method to find unique letters in string plz....
Jun 2, 2010
View khaja naquiuddin 's Profile
Above code will lead to infinite loop.
You have not asked the for loop to increment the i value. it should be this way
for(i=1; i<=10;i++)
{
//your code;
}

In above loop i=1 because the name attribute values are starting with txt1 onwards. there is no txt0 and i<=10 because there is txt10 in the code.

Most important is i++ which you have not specified. i should be incremented to some value.
Jun 2, 2010