有人可以告诉我为什么标头标签中的脚本不起作用。我可以让表单显示,输入我的所有信息,点击提交,但我没有得到输出显示。我一遍又一遍地看着代码但是没看到问题所在。我非常感谢一些帮助。我在学校的老师没多大帮助。
<!doctype html>
<html>
<head>
<title>
Event Scheduler
</title>
</head>
<body>
<header>
<script>
function scheduledEvent(evtdate, evtTitle, maxattendees, coordinator, phonenum, email, infourl, printEvent)
{
this.evtdate = evtdate;
this.evttitle = evtTitle;
this.maxattendees = maxattendees;
this.coordinator = coordinator;
this.phonenum = phonenum;
this.email = email;
this.infourl = infourl;
this.printEvent = printEvent;
function printEvent()
{
document.write("<p>You have scheduled an event named " + this.evtTitle);
document.write(" that will occur on " + this.evtdate + " and allow up to " + this.maxattendees + " attendees.");
document.write("The event is coordinated by " + this.coordinator + " who can be reached at " + this.phonenum);
document.write(" or by email at " + this.email + ". ");
document.write("More information about the event is available at <a href= '" + this.infourl + "'> " + this.infourl + "</a></p>");
}
function validate()
{
with (document.evtForm)
{
evt = new ScheduledEvent(evtDate.value, evtTitle.value, maxattendees.value, evtCoordinator.value, phonenum.value, email.value, infourl.value);
}
with (evt)
{
evt.printEvent();
}
return true;
}
</script>
</header>
<form name= "evtForm" method= "post">
<table>
<tr>
<td>
Event Date: </td><td><input type= date id= "evtDate" /></td></td>
<tr><td>Title:</td><td><input id= "evtTitle" /></td></tr>
<tr><td>
Maximum attendees: </td><td><input id= "evtCoordinator" /><td></tr>
<tr><td>
Phone number (numbers only): </td><td><input type= tel id= "phonenum" /> </td></tr>
<tr><td>
Email: </td><td><input type= email id= "email" /></td></tr>
<tr><td>
More info: </td><td><input type= url id= "infourl" /></td></tr>
</table>
<input type= submit value= "Submit" />
</form>
</body>
</html>
答案 0 :(得分:0)
你的输入字段是你名字属性的所有缺失引号。
你有:
<input type= date id= "evtDate" />
当你应该:
<input type="date" id="evtDate" />
您甚至没有点击提交按钮。
您需要以点击方式或其他方式以某种方式启动该功能。你似乎期望它神奇地开始工作。
答案 1 :(得分:-1)
<!doctype html>
<html>
<head>
<title>
Event Scheduler
</title>
</head>
<body>
<header>
<script>
function scheduledEvent(evtdate, evtTitle, maxattendees, coordinator, phonenum, email, infourl, printEvent)
{
this.evtdate = evtdate;
this.evttitle = evtTitle;
this.maxattendees = maxattendees;
this.coordinator = coordinator;
this.phonenum = phonenum;
this.email = email;
this.infourl = infourl;
this.printEvent = printEvent;
function printEvent()
{
document.write("<p>You have scheduled an event named " + this.evtTitle);
document.write(" that will occur on " + this.evtdate + " and allow up to " + this.maxattendees + " attendees.");
document.write("The event is coordinated by " + this.coordinator + " who can be reached at " + this.phonenum);
document.write(" or by email at " + this.email + ". ");
document.write("More information about the event is available at <a href= '" + this.infourl + "'> " + this.infourl + "</a></p>");
}
function validate()
{
with (document.evtForm)
{
evt = new ScheduledEvent(evtDate.value, evtTitle.value, maxattendees.value, evtCoordinator.value, phonenum.value, email.value, infourl.value);
}
with (evt)
{
evt.printEvent();
}
return true;
}
</script>
</header>
<form name= "evtForm" method= "post">
<table>
<tr>
<td>
Event Date: </td><td><input type= date id= "evtDate" name="evtDate" /></td></td>
<tr><td>Title:</td><td><input id= "evtTitle" name="evtTitle" /></td></tr>
<tr><td>
Maximum attendees: </td><td><input id= "evtCoordinator" name="evtCoordinator" /><td></tr>
<tr><td>
Phone number (numbers only): </td><td><input type= tel id= "phonenum" name="phonenum" /> </td></tr>
<tr><td>
Email: </td><td><input type= email id= "email" name="email" /></td></tr>
<tr><td>
More info: </td><td><input type= url id= "infourl" name="infourl" /></td></tr>
</table>
<input type= submit value= "Submit" />
</form>
</body>
</html>