不能得到一个简单的JavaScript提示工作

问题描述:

<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> 

不能得到一个简单的JavaScript提示工作

+1

我不认为你可以在`form`标签中加入'onclick`。 – Will 2011-02-09 20:54:07

+1

这里没有问题 – Falmarri 2011-02-09 20:54:11

这样的:

<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按钮。

您可以在表单标签改变onClickonSubmit

<form class="r1c1" method="link" action="index.html" onSubmit="editDates();"> 

,改变input键入提交

<input type="submit" name="submit" value="Edit"/> 

这里是与上面的变化为例:JSFiddle