Цикл из книги Javascript библия
Здравствуйтею Пытаюсь понять код с книги (глава 7) вернее подсказка с ответа на контрольные вопросы, не могу понять где ошибка или собака зарыта :D
Аналогично пытаюсь с американского сайта по данной книге вставить схожий код - ничего не работает. Код по адресу http://www.angelfire.com/rnb/sarahwesthead/JSBible/Chapter7.html <html> <head> <script type="text/javascript"> var USStates = new Array[51] USStates[0] = "Alabama" USStates[1] = "Alaska" USStates[2] = "Arizona" USStates[3] = "Arkansas" USStates[4] = "California" USStates[5] = "Colorado" USStates[6] = "Connecticut" USStates[7] = "Delaware" USStates[8] = "District of Colambia" USStates[9] = "Florida" USStates[10] = "Georgia" USStates[11] = "Hawaii" USStates[12] = "Idaho" USStates[13] = "Illinois" USStates[14] = "Indiana" USStates[15] = "Iowa" USStates[16] = "Kansas" USStates[17] = "Kentucky" USStates[18] = "Louisiana" USStates[19] = "Maine" USStates[20] = "Maryland" USStates[21] = "Massachusetts" USStates[22] = "Michigan" USStates[23] = "Minnesota" USStates[24] = "Mississippi" USStates[25] = "Missouri" USStates[26] = "Montana" USStates[27] = "Nebraska" USStates[28] = "Nevada" USStates[29] = "New Hampshire" USStates[30] = "New Jersey " USStates[31] = "New Mexico" USStates[32] = "New York " USStates[33] = "North Carolina " USStates[34] = "North Dakota " USStates[35] = "Ohio" USStates[36] = "Oklahoma" USStates[37] = "Oregon" USStates[38] = "Pennsylvania" USStates[39] = "Rhode Island " USStates[40] = "South Carolina " USStates[41] = "South Dakota" USStates[42] = "Tennessee" USStates[43] = "Texas" USStates[44] = "Utah" USStates[45] = "Vermont" USStates[46] = "Virginia" USStates[47] = "Washington" USStates[48] = "West Virginia" USStates[49] = "Wisconsin" USStates[50] = "Wyoming" var StateEmtered= new Array[51] StateEmtered[0] = 1800 StateEmtered[1] = 1801 StateEmtered[2] = 1802 StateEmtered[3] = 1803 StateEmtered[4] = 1804 StateEmtered[5] = 1805 StateEmtered[6] = 1806 StateEmtered[7] = 1807 StateEmtered[8] = 1808 StateEmtered[9] = 1809 StateEmtered[10] = 1810 StateEmtered[11] = 1811 StateEmtered[12] = 1812 StateEmtered[13] = 1813 StateEmtered[14] = 1814 StateEmtered[15] = 1815 StateEmtered[16] = 1816 StateEmtered[17] = 1817 StateEmtered[18] = 1818 StateEmtered[19] = 1819 StateEmtered[20] = 1820 StateEmtered[21] = 1821 StateEmtered[22] = 1822 StateEmtered[23] = 1823 StateEmtered[24] = 1824 StateEmtered[25] = 1825 StateEmtered[26] = 1826 StateEmtered[27] = 1827 StateEmtered[28] = 1828 StateEmtered[29] = 1829 StateEmtered[30] = 1830 StateEmtered[31] = 1831 StateEmtered[32] = 1832 StateEmtered[33] = 1833 StateEmtered[34] = 1834 StateEmtered[35] = 1835 StateEmtered[36] = 1836 StateEmtered[37] = 1837 StateEmtered[38] = 1838 StateEmtered[39] = 1839 StateEmtered[40] = 1840 StateEmtered[41] = 1841 StateEmtered[42] = 1842 StateEmtered[43] = 1843 StateEmtered[44] = 1844 StateEmtered[45] = 1845 StateEmtered[46] = 1846 StateEmtered[47] = 1847 StateEmtered[48] = 1848 StateEmtered[49] = 1849 StateEmtered[50] = 1850 function getStateDate () { var selectedState = document.entryForm.entry.value; for (var i = 0; i < USStates.length; i++){ if (USStates[i] == selectedState) { break; } } alert ("That state emtered the Union in" + StateEmtered[i] +"."); } </script> </head> <body> <form name="entryForm"> Enter the name of a state <input type="text" name="entry" /> <input type="button" value=" Look Up Entry Date" onclick="getStateDate()" /> </form> </body> </html> |
Цитата:
Цитата:
|
а можно полный код выложить. Пробую array и фигурные и обычные , квадратные - нет результата.
Я начинающий потому вопросы смешные, но изучаю javcript по данной книге, не могу понять в чем ошибка........ Заранее спасибо:) |
yourseowork,
:-/ строка 4 строка 57 new Array(51) |
проверил вставил но результата нет. Как в денвере так и на поддомене http://mysite.seowork.com.ua/test8.php
Аналогично если скопировать и вставить с сайта End of chapter Exercises Exercise 1 http://www.angelfire.com/rnb/sarahwe.../Chapter7.html просто не знаю где ошибка.... |
yourseowork,
код в первом посте рабочий попробуйте его ПОЛНОСТЬЮ скопировать и исправить всего 2 строки. |
не понял зачем там цикл http://codepen.io/animhotep/pen/efDHb
|
Цитата:
|
а, понял
|
Часовой пояс GMT +3, время: 15:13. |