[英]Can't get a simple javascript prompt working
<html>
<title>adsfasdf</title>
<head>
<link rel="stylesheet" type="text/css" href="style.css" >
<script type="text/javascript">
function editDates()
{
var dates = prompt("Fill in date(s) of absence", "Example: Travel 1/7 - 2/10");
}
</script>
</head>
<body bgcolor="#000088">
<table cellspacing="0" border="1" cellpadding="1" width="100%" height="100%">
<tr>
<td>name</td><td>
<form class="r1c1" method="link" action="index.html" onClick="editDates();">
<input type="button" name="submit" value="Edit"/></form>
</td>
</tr>
</table>
</body>
this: 这个:
<script type=type="text/javascript">
should be: 应该:
<script type="text/javascript">
Example: http://jsfiddle.net/hDpyN/ 示例: http : //jsfiddle.net/hDpyN/
尝试:
<input type="button" name="submit" value="Edit" onClick="editDates();"/>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<title>asdfasdf</title>
</head>
<body bgcolor="#000088">
<script type="text/javascript">
function editDates()
{
var dates = prompt("Fill in date(s) of absence", "Example: Travel 1/7 - 2/10");
}
</script>
<table cellspacing="0" border="1" cellpadding="1" width="100%" height="100%">
<tr>
<td>name</td><td>
<form class="r1c1" method="link" action="index.html" >
<input type="button" name="submit" value="Edit" onclick="editDates();" />
</form>
</td>
</tr></table>
</body>
</html>
You need to use either onsubmit in the form or onclick in the button. 您需要使用表单中的onsubmit或按钮中的onclick。
you can change the onClick
to onSubmit
in the form tag: 您可以在表单标签中将
onClick
更改为onSubmit
:
<form class="r1c1" method="link" action="index.html" onSubmit="editDates();">
and change the input
to type submit 并更改
input
以键入submit
<input type="submit" name="submit" value="Edit"/>
Here is an example with the changes above: JSFiddle 这是上述更改的示例: JSFiddle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.