无法获得简单的javascript提示工作

时间:2011-02-09 20:51:29

标签: javascript html prompt

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

4 个答案:

答案 0 :(得分:6)

这样:

<script type=type="text/javascript">

应该是:

<script type="text/javascript">

示例: http://jsfiddle.net/hDpyN/

答案 1 :(得分:0)

尝试:

   <input type="button" name="submit" value="Edit" onClick="editDates();"/>

答案 2 :(得分:0)

<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或在按钮中单击。

答案 3 :(得分:0)

您可以将表单标记中的onClick更改为onSubmit

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

并将input更改为输入提交

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

以下是上述更改的示例: JSFiddle