[英]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>
這個:
<script type=type="text/javascript">
應該:
<script type="text/javascript">
示例: 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>
您需要使用表單中的onsubmit或按鈕中的onclick。
您可以在表單標簽中將onClick
更改為onSubmit
:
<form class="r1c1" method="link" action="index.html" onSubmit="editDates();">
並更改input
以鍵入submit
<input type="submit" name="submit" value="Edit"/>
這是上述更改的示例: JSFiddle
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.