2
<html dir = rtl>
    <head>
        <title> </title>
        <meta HTTP-EQUIV="Content-language" CONTENT="ar">
        <script type="javascript">
        function d()
            {               
                document.getElementById("sName").innerHTML ='Name submitted';
            }

    </script>
    </head>
    <body>
       <form name = "Info" method = "set" action = "">
           <table  border = "0" width = "40%" align = "center">
           <tr>
                   <td> الاســــــــــــــــم: </td>
                   <td> <input type="text" name = "CurName" size = "31"> </td>
                   <td> <p id = "sName"> </p> </td>
               </tr>

               <tr>
                   <td> العــــــــــــــــمر :</td>
                   <td> <input type = "text" name = "CurAddress" size = "10"></td>
           <td> <p id = "sAddress"> </p> </td>
               </tr>

               <tr>
                   <td> العنـــــــــــــوان :</td>
                   <td> <input type = "text" name = "CurAddress" size = "45"></td>
           <td> <p id = "sAddress"> </p> </td>
               </tr>

               <tr>
                   <td> الحالــــــــــــــــة :</td>
                   <td> <input type = "radio" name = "Mar" > متزوج<input type = "radio" name = "Sin" > أعزب</td>
           <td> <p id = "SitName"> </p> </td>
               </tr>

               <tr>                   
                  <td colspan = 2 align = center> <button type = "submit" onClick = "d(); return false;">ارسال </button>  <button type = "reset">مسح</button> </td>                 
               </tr>
          </table>
       </form>
    </body>
</html>

当我按下提交按钮时,我预计第一个文本框旁边的一些单词会消失,但什么也没发生。有人可以向我解释问题出在哪里吗?

4

3 回答 3

3

您没有正确定义您的script标签。适当的值将是text/javascript

<script type="text/javascript">

代替

<script type="javascript">
于 2013-05-26T10:28:47.080 回答
2

您的 js 代码是正确的,但您必须更改它

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

在这里查看您的代码,它在 jsfiddle 中完美运行

      http://jsfiddle.net/WxtJ3/
于 2013-05-26T10:35:12.873 回答
1
<script type="text/javascript">

和改变

<button type = "submit" onClick = "d();">

<button type = "button" onClick = "d();">

否则你的页面会重新加载

于 2013-05-26T10:28:05.437 回答