html / javascript / css如何组合和修复此问题

时间:2013-04-25 02:18:24

标签: javascript html function

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

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

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

1 个答案:

答案 0 :(得分: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")

   }

   }