JavaScript未在HTML中执行文本框值

JavaScript未在HTML中执行文本框值,javascript,html,Javascript,Html,我对HTML中的JavaScript还不熟悉,并得到了使用JS编写Mad Lib表单的项目。我对它进行了多次编码和检查,但我没有发现代码的问题:程序没有更改HTML文档中的文本框值。你能帮忙吗? 代码: 函数madLib(){ 变量名、宾语、宾语二、形容词、副词、动词、地点、语气、建筑结构; name=document.MadLibForm.name.value; object=document.MadLibForm.object.value; objectTwo=document.MadLi

我对HTML中的JavaScript还不熟悉,并得到了使用JS编写Mad Lib表单的项目。我对它进行了多次编码和检查,但我没有发现代码的问题:程序没有更改HTML文档中的文本框值。你能帮忙吗? 代码:

函数madLib(){
变量名、宾语、宾语二、形容词、副词、动词、地点、语气、建筑结构;
name=document.MadLibForm.name.value;
object=document.MadLibForm.object.value;
objectTwo=document.MadLibForm.objectwo.value;
形容词=document.MadLibForm.形容词.value;
副词=document.MadLibForm.副词.value;
动词=document.MadLibForm.verb.value;
place=document.MadLibForm.place.value;
mood=document.MadLibForm.mood.value;
buildingStructure=name+“去了很久。”+name+“喜欢”+PLACE+“因为那是他/她小时候最喜欢的地方。”+name+“把“+形容词+”+object+”带到他/她习惯的“+地点+”+副词+动词+”。他/她还带了“+objectTwo+“与他/她在一起,但在访问期间根本没有使用它。尽管如此,在访问结束时,他/她非常“+心情+”;
document.MadLibForm.displayFullMadLib.value=buildingStructure;
}

疯狂填词
函数madLib(){
变量名、宾语、宾语二、形容词、副词、动词、地点、语气、建筑结构;
name=document.MadLibForm.name.value;
object=document.MadLibForm.object.value;
objectTwo=document.MadLibForm.objectwo.value;
形容词=document.MadLibForm.形容词.value;
副词=document.MadLibForm.副词.value;
动词=document.MadLibForm.verb.value;
place=document.MadLibForm.place.value;
mood=document.MadLibForm.mood.value;
buildingStructure=name+“去了很久。”+name+“喜欢”+PLACE+“因为那是他/她小时候最喜欢的地方。”+name+“把“+形容词+”、“+object+”带到他/她习惯的“+地点+”、“+副词+动词+”。他/她还带了“+objectTwo+”与他/她在一起,但在访问期间根本没有使用它。但是,在访问结束时,他/她非常“心情+”;
document.MadLibForm.displayFullMadLib.value=buildingStructure;
}
古怪的疯狂的自由党
你的名字
对象
另一个物体
放置
动词
形容词
副词
情绪
打字错误:

objectTwo = document.MadLibForm.objectwo.value;
应该是

objectTwo = document.MadLibForm.objecttwo.value;
请注意,两次更改后,两个“t”可以正常工作

  • 更改:

    objectTwo = document.MadLibForm.objectwo.value;
    
    致:

  • object
    替换为中的
    object

    ..." took the " + adjective + " " + object + " with him to the " + place ...+ 
    
  • JS:

    madLib = function() {
          var name, object, objectTwo, adjective, adverb, verb, place, mood, buildingStructure;
          name = document.MadLibForm.name.value;
          object = document.MadLibForm.object.value;
          objectTwo = document.MadLibForm.objecttwo.value;
          adjective = document.MadLibForm.adjective.value;
          adverb = document.MadLibForm.adverb.value;
          verb = document.MadLibForm.verb.value;
          place = document.MadLibForm.place.value;
          mood = document.MadLibForm.mood.value;
    
          buildingStructure = name + " went to PLACE after a long time. " + name + " loved " + place + " because it was his/her favorite place when she was a kid. " + name + " took the " + adjective + " " + object + " with him to the " + place + ", which he/she used to it " + adverb + verb + ". He/She also took " + objectTwo + " with him/her, but did not use it at all during the visit. Still, at the end of the visit, he/she was very " + mood + " .";
    
          document.MadLibForm.displayFullMadLib.value = buildingStructure;
    }
    
    madLib = function() {
          var name, object, objectTwo, adjective, adverb, verb, place, mood, buildingStructure;
          name = document.MadLibForm.name.value;
          object = document.MadLibForm.object.value;
          objectTwo = document.MadLibForm.objecttwo.value;
          adjective = document.MadLibForm.adjective.value;
          adverb = document.MadLibForm.adverb.value;
          verb = document.MadLibForm.verb.value;
          place = document.MadLibForm.place.value;
          mood = document.MadLibForm.mood.value;
    
          buildingStructure = name + " went to PLACE after a long time. " + name + " loved " + place + " because it was his/her favorite place when she was a kid. " + name + " took the " + adjective + " " + object + " with him to the " + place + ", which he/she used to it " + adverb + verb + ". He/She also took " + objectTwo + " with him/her, but did not use it at all during the visit. Still, at the end of the visit, he/she was very " + mood + " .";
    
          document.MadLibForm.displayFullMadLib.value = buildingStructure;
    }