以下ソースコードの<output>0</output>のとこに、submitを押して計算結果を反映させるにはどうすればいいですか?
HTML
1コード 2 <FORM action="BmiAction"> 3 身長:<INPUT size="6" type="text" maxlength="4" placeholder="1.8" 4 name="hight" pattern="^([1-9]\d*|0)(\.\d+)?$" required 5 title="小数点以下を含む半角数値のみ受け付けます">m 6 体重:<INPUT size="6" 7 type="text" maxlength="3" placeholder="68" name="weight" 8 pattern="^[0-9]{2,}" required title="2桁以上の半角数字のみ受け付けます">kg 9 <SELECT class="design-select-box"> 10 <OPTION>男</OPTION> 11 <OPTION>女</OPTION> 12 <OPTION>グレイゾーン</OPTION> 13 14 </SELECT> <INPUT type="submit" value="BMIからオススメ商品を表示→" 15 style="background-color: #ffff99" 16 onmouseover="this.style.background='#99ccff'" 17 onmouseout="this.style.background='#ffff99'" onclick=""> <BR>あなたのBMI値は 18 <output>0</output> 19 です 20 </FORM>
見づらくてすいません!
下記がform actionのBmiActionの内容です
java
1コード public class BmiAction extends ActionSupport{ 2 3 /** 4 * シリアルバージョンID 5 */ 6 private static final long serialVersionUID = -6470489626126602974L; 7 public double hight; 8 public int weight; 9 public int kcal; 10 public String result=ERROR; 11 public List<BMIDTO> pickupList=new ArrayList<BMIDTO>(); 12 13/** 14 * BMIを算出してお勧めの商品をリストに格納するメソッド 15 * @param hight 身長 16 * @param weight 体重 17 * @param kcal カロリー 18 * @param pickupList おすすめ商品のリスト 19 * @return result 結果 20 */ 21 public String execute()throws Exception{ 22 23 double bmi = weight/(hight*hight); 24 25 26 if(bmi<25){ 27 kcal=1; 28 }if(bmi>30){ 29 kcal=3; 30 }else{ 31 kcal=2; 32 } 33 34 BmiDAO dao=new BmiDAO(); 35 boolean resultDAO=dao.select(kcal); 36 37 if(resultDAO){ 38 //pickupList.clear(); 39 pickupList.addAll(dao.getPickupList()); 40 41 result=SUCCESS; 42 } 43 return result; 44 } 45 46 /** 47 * 身長情報取得メソッド 48 */ 49 public double getHight() { 50 return hight; 51 } 52 53 /** 54 * 身長情報格納メソッド 55 */ 56 public void setHight(double hight) { 57 this.hight = hight; 58 } 59 60 /** 61 * 体重情報取得メソッド 62 */ 63 public int getWeight() { 64 return weight; 65 } 66 67 /** 68 * 体重情報格納メソッド 69 */ 70 public void setWeight(int weight) { 71 this.weight = weight; 72 } 73 74 /** 75 * カロリー情報取得メソッド 76 */ 77 public int getKcal() { 78 return kcal; 79 } 80 81 /** 82 * カロリー情報格納メソッド 83 */ 84 public void setKcal(int kcal) { 85 this.kcal = kcal; 86 } 87 88 /** 89 * おすすめ商品情報取得メソッド 90 */ 91 public List<BMIDTO> getPickupList() { 92 return pickupList; 93 } 94 95 /** 96 * おすすめ商品情報登録メソッド 97 */ 98 public void setPickupList(List<BMIDTO> pickupList) { 99 this.pickupList = pickupList; 100 } 101 102} 103
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/04/14 14:56
2016/04/18 02:41