Код работал отлично раньше. Я пробовал много вещей, чтобы исправить это, и это, кажется, не хочет работать. Это потому, что слишком много переменных? Кроме того, я бы хотел добавить кнопку, чтобы значения (массив) отображались при размещении кнопки «Случайная». Благодарность!

{amp}lt;html{amp}gt;{amp}lt;head{amp}gt; {amp}lt;title{amp}gt; Mad Libs Story {amp}lt;/title{amp}gt; {amp}lt;script{amp}gt; function getVars() { var firstPerson = String(document.getElementbyId("personOne").value); var firstAdjective = String(document.getElementById("adjectiveOne").value); var secondAdjective = String(document.getElementById("adjectiveTwo").value); var thirdAdjective = String(document.getElementById("adjectiveThree").value); var secondPerson = String(document.getElementById("personTwo").value); var fourthAdjective = String(document.getElementById("adjectiveFour").value); var firstNumber = Number(document.getElementById("numberOne").value); var thirdPerson = String(document.getElementById("personThree").value); document.getElementById("madLibCreation").innerHTML = "Dear "   firstPerson   ",Overall, the camp is "   firstAdjective   "The camp counselors are "   secondAdjective   "and the food is "   thirdAdjective   ".Today, I met someone named "   secondPerson   "and we become "   fourthAdjective   "friends. I hope to write to you in "   firstNumber   "days.Sincerely,"   thirdPerson   "."; } {amp}lt;/script{amp}gt; {amp}lt;/head{amp}gt; {amp}lt;body{amp}gt; {amp}lt;h3{amp}gt; Welcome to Mad Libs! Please type in the prompted Information. Then press the submit button. Have fun! {amp}lt;/h3{amp}gt; {amp}lt;p{amp}gt; Name of Person in Room: {amp}lt;input type="text" id="personOne"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Adjective: {amp}lt;input type="text" id="adjectiveOne"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Adjective: {amp}lt;input type="text" id="adjectiveTwo"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Adjective: {amp}lt;input type="text" id="adjectiveThree"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Name of Someone: {amp}lt;input type="text" id="personTwo"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Adjective: {amp}lt;input type="text" id="adjectiveFour"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Number: {amp}lt;input type="text" id="numberOne"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Name of Someone: {amp}lt;input type="text" id="personThree"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; {amp}lt;input type="submit" value="Get My MadLib Creation!" onclick="getVars();"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p id="madLibCreation"{amp}gt;{amp}lt;/p{amp}gt; {amp}lt;/body{amp}gt;{amp}lt;/html{amp}gt; 

Шеннон Сирл

новый участник этого сайта. Будьте внимательны, спрашивая разъяснения, комментируя и отвечая. Проверьте наш

Правила поведения

,

Небольшая опечатка в var firstPerson = String(document.getElementbyId("personOne").value); , getElementbyId требуется заглавная getElementById B: getElementById . Вот код с исправленным типом.

 {amp}lt;html{amp}gt;{amp}lt;head{amp}gt; {amp}lt;title{amp}gt; Mad Libs Story {amp}lt;/title{amp}gt; {amp}lt;script{amp}gt; function getVars() { var firstPerson = String(document.getElementById("personOne").value); var firstAdjective = String(document.getElementById("adjectiveOne").value); var secondAdjective = String(document.getElementById("adjectiveTwo").value); var thirdAdjective = String(document.getElementById("adjectiveThree").value); var secondPerson = String(document.getElementById("personTwo").value); var fourthAdjective = String(document.getElementById("adjectiveFour").value); var firstNumber = Number(document.getElementById("numberOne").value); var thirdPerson = String(document.getElementById("personThree").value); document.getElementById("madLibCreation").innerHTML = "Dear "   firstPerson   ",Overall, the camp is "   firstAdjective   "The camp counselors are "   secondAdjective   "and the food is "   thirdAdjective   ".Today, I met someone named "   secondPerson   "and we become "   fourthAdjective   "friends. I hope to write to you in "   firstNumber   "days.Sincerely,"   thirdPerson   "."; } {amp}lt;/script{amp}gt; {amp}lt;/head{amp}gt; {amp}lt;body{amp}gt; {amp}lt;h3{amp}gt; Welcome to Mad Libs! Please type in the prompted Information. Then press the submit button. Have fun! {amp}lt;/h3{amp}gt; {amp}lt;p{amp}gt; Name of Person in Room: {amp}lt;input type="text" id="personOne"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Adjective: {amp}lt;input type="text" id="adjectiveOne"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Adjective: {amp}lt;input type="text" id="adjectiveTwo"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Adjective: {amp}lt;input type="text" id="adjectiveThree"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Name of Someone: {amp}lt;input type="text" id="personTwo"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Adjective: {amp}lt;input type="text" id="adjectiveFour"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Number: {amp}lt;input type="text" id="numberOne"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; Name of Someone: {amp}lt;input type="text" id="personThree"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p{amp}gt; {amp}lt;input type="submit" value="Get My MadLib Creation!" onclick="getVars();"{amp}gt; {amp}lt;/p{amp}gt; {amp}lt;p id="madLibCreation"{amp}gt;{amp}lt;/p{amp}gt; {amp}lt;/body{amp}gt;{amp}lt;/html{amp}gt;