简体   繁体   English

html / javascript / css如何结合并解决此问题

[英]html/javascript/css how to combine and fix this

ok well this is everything but my problem is very small.. the page is setup, the point system is correct all i need to do is have the inputs show match up to the point system and show the alert associated with it. 好的,这就是一切,但是我的问题很小。.页面已设置,积分系统是正确的,我需要做的就是让输入显示与积分系统匹配并显示与之相关的警报。

the issue is when a user enters commands in the text box's it should alert what there rank is (pro,novice,beginner,noob) 问题是,当用户在文本框中输入命令时,它应该警告等级(专业,新手,初学者,菜鸟)

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

Your HTML is riddled with invalid markup. 您的HTML充满了无效的标记。 I've cleaned it up a little bit (it still has issues), and added an onsubmit to the form to call your system function. 我已经整理了一下(它仍然有问题),并在表单中添加了一个onsubmit来调用您的系统函数。 I modified your system function a bit too. 我也修改了您的系统功能。 You weren't referring to your variables with the right names all the time. 您并不是一直在用正确的名称来引用变量。 (points instead of point, etc.). (以点代替点等)。 Next time, do some typo checking before you post a question or code. 下次, 发布问题或代码之前进行一些错字检查。 Generally one or two typos is accepted as just being overlooked, but yours had a lot. 通常只接受一两个错别字即可,但您的错字很多。 Just a few minutes of looking it over on your part would have gotten you tons closer to begin with. 只需几分钟查看一下您的位置,便可以使您更接近一开始。

HTML 的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 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")

   }

   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM