Подскажите ,что не так
Здравствуйте,подскажите:
Вот скрипт: for(m=0;m<8;m++){ document.forma1.q1.value=a[m];} Как сделать,чтобы по счётчику выполнялось: document.forma1.q1.value=a1; document.forma1.q2.value=a2; document.forma1.q3.value=a3; document.forma1.q4.value=a4; document.forma1.q5.value=a5; document.forma1.q6.value=a6; document.forma1.q7.value=a7; document.forma1.q8.value=a8; |
document.forma1["q"+m].value=a[m];
|
Не работает(
|
А что у вас в a?
И что говорит firebug? |
a есть массив с некоторыми элементами,m тут индекс
firebug не для моего хрома:) |
Цитата:
в твоей голове не воозникало мысли что НУЖНО прислать нам массив a ???? |
<html>
<head> <style type="text/css"> input.q1{} input.q2{width:25px;} </style> <script type="text/JavaScript"> function sRand() { return Math.random() > 0.5 ? 1 : -1; } function f1(){ var a = new Array(1,2,3,4,5,6,7,8,9); a.sort(sRand); var m; for(m=0;m<8;m++){ document.forma1.q1.value=a[m];} } </script> </head> <body> <form name='forma1'> <input type='text' name='q1' class='q1'><input type='text' name='q2' class='q1'> <input type='text' name='' class='q2'><input type='text' name='' class='q2'> <br> <input type='text' name='q3' class='q1'><input type='text' name='q4' class='q1'> <input type='text' name='' class='q2'><input type='text' name='' class='q2'> <br> <input type='text' name='q5' class='q1'><input type='text' name='q6' class='q1'> <input type='text' name='' class='q2'><input type='text' name='' class='q2'> <br> <input type='text' name='q7' class='q1'><input type='text' name='q8' class='q1'> <input type='text' name='' class='q2'><input type='text' name='' class='q2'> <br> <br><input type="button" onClick='f1()' value="Îáíîâèòü"> </body> </html> |
Цитата:
Цитата:
|
Цитата:
|
Цитата:
|
Часовой пояс GMT +3, время: 10:35. |