1

好的,这就是一切,但我的问题很小.. 页面已设置,点系统是正确的,我需要做的就是让输入显示与点系统匹配并显示与之相关的警报。

问题是当用户在文本框中输入命令时,它应该提醒排名是什么(专业、新手、初学者、菜鸟)

    <HTML>
    <HEAD>
    <script>
     function system(){

     var point=document.world.system.txt_points.value
     var tourn=document.world.system.txt_tourn.value
     var level=document.world.system.txt_level.value
     var check=document.world.system.txt_check.value
     var results=document.world.system.txt_results.value

     if ((point>=100000)&&(level>10)&&(tourn>25))
     {
     results=alert("pro status")
     }
    if((points>=100000)&&(level>10))
    {
   alert("Novice")
    }
   if (point>=100000)
   {
   alert("beginner")
   }

   if (points<100000)
   {
   alert("noob")
   }

   if (check=true)
   {
   alert("pro")

   }

   }
   </script>
   </HEAD>
   <BODY>
   <form name="world">
   <center>
   <table border=3>
   </center>

   <b>
   <th><font size='16'>defined</font></th>
   </b>
   <th><font size='16'>user input</font></th>

   </center>
   <tr>
   <td>How many points have you earned?</td>
   <td>
   <input type="textbox" name="txt_points" size='50'id='point'>
   </td>
   </tr>


   <tr>
   <td>How many tournaments have you played in?</td>
   <td>
   <input type="text box" size='50'id='tourn' name='txt_tourn'>
   </td>
   </tr>

   <tr>
   <td>highest level</td>
   <td>
   <input type="text box" size='50'id='level' name ='txt_level'>
   </td>
   </tr>

   <tr>
   <td>Have you won atleast 1 tournement</td>
   <td

    ><center>
       <input type="checkbox"id='check' name=txt_check>
       </center>
      </td>
    </tr>
    <tr>
    <td>your world of wizards ranking is </td>
    <td><center>
    <input type="submit"value ="submit">
    <br>
    <input type ="text box" name ="txt_results">
    </center>


    </td>
    </tr>
    </table>
    </center>
    </form>
4

1 回答 1

0

您的 HTML 充满了无效标记。我已经对其进行了一些清理(它仍然存在问题),并在表单中添加了一个 onsubmit 以调用您的系统函数。我也稍微修改了你的系统功能。您并没有一直使用正确的名称来引用您的变量。(点而不是点等)。下次,在发布问题或代码之前进行一些拼写检查。通常一两个错别字被认为只是被忽略了,但你的错字很多。只需几分钟的时间就可以让你更接近开始。

HTML

   <form name="world" method="post" onsubmit="system(); return false;">

   <table border=3>



   <th><font size='16'>defined</font></th>

   <th><font size='16'>user input</font></th>


   <tr>
   <td>How many points have you earned?</td>
   <td>
   <input type="text" name="txt_points" size='50' id='point'>
   </td>
   </tr>


   <tr>
   <td>How many tournaments have you played in?</td>
   <td>
   <input type="text" size='50' id='tourn' name='txt_tourn'>
   </td>
   </tr>

   <tr>
   <td>highest level</td>
   <td>
   <input type="text" size='50' id='level' name ='txt_level'>
   </td>
   </tr>

   <tr>
   <td>Have you won atleast 1 tournement</td>
   <td

    >
       <input type="checkbox"id='check' name=txt_check>

      </td>
    </tr>
    <tr>
    <td>your world of wizards ranking is </td>
    <td>
    <input type="submit"value ="submit">
    <br>
    <input type ="text box" name ="txt_results">



    </td>
    </tr>
    </table>

    </form>

JAVASCRIPT

function system(){

     var point=document.world.txt_points.value;
     var tourn=document.world.txt_tourn.value;
     var level=document.world.txt_level.value;
     var check=document.world.txt_check.value;
     var results=document.world.txt_results.value

     if ((point>=100000)&&(level>10)&&(tourn>25))
     {
     alert("pro status")
     }
    if((point>=100000)&&(level>10))
    {
   alert("Novice")
    }
   if (point>=100000)
   {
   alert("beginner")
   }

   if (point<100000)
   {
   alert("noob")
   }

   if (check==true)
   {
   alert("pro")

   }

   }
于 2013-04-25T03:33:58.450 回答