dtx6087 2016-12-17 05:35
浏览 63
已采纳

我想制作一个狗计算器,显示百分比[关闭]

Here is my code of Index.html:-

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Untitled Document</title>
 </head>

 <body>
 <h1>Dog Love Calculator</h1>
<form action="dog2.php" method="post" name="DogCal" onsubmit="return validateForm()" >

<h3>Do Your Dog Hugs you with Eyes?</h3>

<strong><input name="hugs" type="radio" value="hugs_1" />
Yes</strong><br>
<input name="hugs" type="radio" value="hugs_2" />
<strong>No</strong><br>
<input name="hugs" type="radio" value="hugs_3" />
<strong>Maybe</strong><br> <br>

<h3>Does Your Dog Lifts his Eyebrows when Meets You?</h3>
<input name="eyebrows" type="radio" value="eyebrows_1" />
<strong>Yes, Left One</strong><br />
<input name="eyebrows" type="radio" value="eyebrows_2" />
<strong>No, Right One</strong><br />
<input name="eyebrows" type="radio" value="eyebrows_3" />
<strong>No</strong><br /><br>

<h3>What Signs does He show when you Leave Home?</h3>
<input name="signs" type="radio" value="signs_1" />
<strong>Panic</strong><br />
<input name="signs" type="radio" value="signs_2" />
<strong>Calmness</strong><br /><br>

<h3>Where does he like to sleep?</h3>

<strong><input name="sleep" type="radio" value="sleep_1" />
On His Bed</strong><br>
<input name="sleep" type="radio" value="sleep_2" />
<strong>Beside you or on your bed</strong><br><br>

<h3>Does he Give you His favorite toy?</h3>
<input name="toy" type="radio" value="toy_1" />
<strong>Yes</strong><br />
<input name="toy" type="radio" value="toy_2" />
<strong>No</strong><br />
<input name="toy" type="radio" value="toy_3" />
<strong>Sometimes</strong><br /><br>

<h3>Does he take Interest in what you are doing?</h3>
<input name="interest" type="radio" value="interest_1" />
<strong>Yes</strong><br />
<input name="interest" type="radio" value="interest_2" />
<strong>No</strong><br /><br>

<h3>When you call your dog, does your pup quickly Returns Your Call?</h3>
<input name="call" type="radio" value="call_1" />
<strong>Yes</strong><br />
<input name="call" type="radio" value="call_2" />
<strong>No</strong><br /><br>

<h3>How Your Dog wags his tail in front of you?</h3>
<input name="tail" type="radio" value="tail_1" />
<strong>To the Right</strong><br />
<input name="tail" type="radio" value="tail_2" />
<strong>To the Left</strong><br /><br>

<h3>Does he Yawn With You?</h3>
<input name="yawn" type="radio" value="yawn_1" />
<strong>Yes</strong><br />
<input name="yawn" type="radio" value="yawn_2" />
<strong>No</strong><br />
<input name="yawn" type="radio" value="yawn_3" />
<strong>Sometimes</strong><br /><br>

<h3>How your Dog Move his ears in Front of You? </h3>
<input name="ear" type="radio" value="ear_1" />
<strong>Shift The Left Ear</strong><br />
<input name="ear" type="radio" value="ear_2" />
<strong>Shift The Right Ear</strong><br /><br>

<input type="submit" name="SubmitButton" value="Submit" >

<input type="reset" value="Reset">
</form>
</body>
</html>

Dog2.php is action file.

I want 10% for every yes and 3% for every No, and 5% of every maybe, sometime etc. at the end the main echo will total of their results.

If someone chose: yes, yes, no,yes, sometimes.

Then the result will be like this: 10 +10+3+10+5 = 38

And echo will be like that

Your dog love you 38%.. like this.

</div>
  • 写回答

2条回答 默认 最新

  • douao1959 2016-12-17 09:02
    关注

    i made a quick test. this works for me. you can copy and play with it.

    dog.html

         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>Untitled Document</title>
     </head>
    
     <body>
     <h1>Dog Love Calculator</h1>
    <form action="dog2.php" method="post" name="DogCal" onsubmit="return validateForm()" >
    
    <h3>Do Your Dog Hugs you with Eyes?</h3>
    
    <strong><input name="hugs" type="radio" value="10" />Yes</strong><br>
    <input name="hugs" type="radio" value="3" /><strong>No</strong><br>
    <input name="hugs" type="radio" value="5" /><strong>Maybe</strong><br> <br>
    
    <h3>Does Your Dog Lifts his Eyebrows when Meets You?</h3>
    <input name="eyebrows" type="radio" value="10" /><strong>Yes, Left One</strong><br />
    <input name="eyebrows" type="radio" value="3" /><strong>No, Right One</strong><br />
    <input name="eyebrows" type="radio" value="5" /><strong>No</strong><br /><br>
    
    <h3>What Signs does He show when you Leave Home?</h3>
    <input name="signs" type="radio" value="10" /><strong>Panic</strong><br />
    <input name="signs" type="radio" value="5" /><strong>Calmness</strong><br /><br>
    
    <h3>Where does he like to sleep?</h3>
    
    <input name="sleep" type="radio" value="10" /><strong>On His Bed</strong><br>
    <input name="sleep" type="radio" value="5" /><strong>Beside you or on your bed</strong><br><br>
    
    <h3>Does he Give you His favorite toy?</h3>
    <input name="toy" type="radio" value="10" /><strong>Yes</strong><br />
    <input name="toy" type="radio" value="3" /><strong>No</strong><br />
    <input name="toy" type="radio" value="5" /><strong>Sometimes</strong><br /><br>
    
    <h3>Does he take Interest in what you are doing?</h3>
    <input name="interest" type="radio" value="10" /><strong>Yes</strong><br />
    <input name="interest" type="radio" value="3" /><strong>No</strong><br /><br>
    
    <h3>When you call your dog, does your pup quickly Returns Your Call?</h3>
    <input name="call" type="radio" value="10" /><strong>Yes</strong><br />
    <input name="call" type="radio" value="3" /><strong>No</strong><br /><br>
    
    <h3>How Your Dog wags his tail in front of you?</h3>
    <input name="tail" type="radio" value="10" /><strong>To the Right</strong><br />
    <input name="tail" type="radio" value="3" />a<strong>To the Left</strong><br /><br>
    
    <h3>Does he Yawn With You?</h3>
    <input name="yawn" type="radio" value="10" /><strong>Yes</strong><br />
    <input name="yawn" type="radio" value="3" /><strong>No</strong><br />
    <input name="yawn" type="radio" value="5" /><strong>Sometimes</strong><br /><br>
    
    <h3>How your Dog Move his ears in Front of You? </h3>
    <input name="ear" type="radio" value="10" /><strong>Shift The Left Ear</strong><br />
    <input name="ear" type="radio" value="3" /><strong>Shift The Right Ear</strong><br /><br>
    
    <input type="submit" name="SubmitButton" value="Submit" >
    
    <input type="reset" value="Reset">
    </form>
    </body>
    </html>
    

    dog2.php

    <?php
    $hugs = $_POST['hugs'];
    $eyebrows = $_POST['eyebrows'];
    $signs = $_POST['signs'];
    $sleep = $_POST['sleep'];
    $toy = $_POST['toy'];
    $interest = $_POST['interest'];
    $call = $_POST['call'];
    $tail = $_POST['tail'];
    $yawn = $_POST['yawn'];
    $ear = $_POST['ear'];
    
    echo 'hugs: '.$hugs.'<br>';
    echo 'eyebrows: '.$eyebrows.'<br>';
    echo 'signs: '.$signs.'<br>';
    echo 'sleep: '.$sleep.'<br>';
    echo 'toy: '.$toy.'<br>';
    echo 'interest: '.$interest.'<br>';
    echo 'call: '.$call.'<br>';
    echo 'tail: '.$tail.'<br>';
    echo 'yawn: '.$yawn.'<br>';
    echo 'ear: '.$ear.'<br>';
    
    echo 'total: '.($hugs+$eyebrows+$signs+$sleep+$toy+$interest+$call+$tail+$yawn+$ear);
    ?>
    

    hope this help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab