本文目錄一覽:
用html jsp 設計。用日期查詢星座,請問我的問題出在哪裡,查詢不到
就是說:你輸入一個日期要顯示相應的星座對吧?
有可能是你的判斷不對,你輸入年月日,但是星座只要取月-日就好了,再判斷這個日期在哪個星座的日期之間
用html jsp 語言設計。 用日期查詢星座,請問我的問題出在哪裡
截圖的代碼看不清。
提供示例代碼供參考:
function xingzuo() {
var start = 1901, date=document.getElementById(“txtDay”).value, month=document.getElementById(“txtMonth”).value;;
with (document.getElementById(“txtXZ”)){
if (month == 1 date =20 || month == 2 date =18) {value = “水瓶座”;}
//if (month == 1 date 31) {value = “Huh?”;}
if (month == 2 date =19 || month == 3 date =20) {value = “雙魚座”;}
//if (month == 2 date 29) {value = “Say what?”;}
if (month == 3 date =21 || month == 4 date =19) {value = “白羊座”;}
//if (month == 3 date 31) {value = “OK. Whatever.”;}
if (month == 4 date =20 || month == 5 date =20) {value = “金牛座”;}
//if (month == 4 date 30) {value = “I’m soooo sorry!”;}
if (month == 5 date =21 || month == 6 date =21) {value = “雙子座”;}
//if (month == 5 date 31) {value = “Umm … no.”;}
if (month == 6 date =22 || month == 7 date =22) {value = “巨蟹座”;}
//if (month == 6 date 30) {value = “Sorry.”;}
if (month == 7 date =23 || month == 8 date =22) {value = “獅子座”;}
//if (month == 7 date 31) {value = “Excuse me?”;}
if (month == 8 date =23 || month == 9 date =22) {value = “室女座”;}
//if (month == 8 date 31) {value = “Yeah. Right.”;}
if (month == 9 date =23 || month == 10 date =22) {value = “天秤座”;}
//if (month == 9 date 30) {value = “Try Again.”;}
if (month == 10 date =23 || month == 11 date =21) {value = “天蠍座”;}
//if (month == 10 date 31) {value = “Forget it!”;}
if (month == 11 date =22 || month == 12 date =21) {value = “人馬座”;}
//if (month == 11 date 30) {value = “Invalid Date”;}
if (month == 12 date =22 || month == 1 date =19) {value = “摩羯座”;}
//if (month == 12 date 31) {value = “No way!”;}
}
}
怎麼用JSP編一個關於星座的程序
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; public class xingzuo extends HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException { res.setContentType(“text/html”); res.setCharacterEncoding(“GB2312”); PrintWriter out = res.getWriter(); String getmonth = req.getParameter(“month”); int month = new Integer(getmonth).intValue(); String getday = req.getParameter(“day”); int day = new Integer(getday).intValue(); String test=req.getParameter(“T1”); boolean err=false; int xingzuonumber=0; int fenjie[]={21,19,21,21,22,22,23,24,24,24,23,22}; int zuida[]={31,29,31,30,31,30,31,31,30,31,30,31}; String xingzuo[]={“水平座”,”雙魚座”,”白羊座”,”金牛座”,”雙子座”,”巨蟹座”,”獅子座”,”處女座”,”天秤座”,”天蠍座”,”人馬座”,”山羊座”}; String xingge[]=new String[12]; xingge[0]=”這個星座常被稱為’天才星座’或’未來星座’。”; xingge[7]=”處女座的特色是有豐富的知性,做事一絲不苟,”; xingge[8]=”天秤座的人愛好美與和諧,也相當仁慈並富有同情心,”; xingge[9]=”這個星座的人有著強烈的第六感、神秘的探視能力及吸引力,”; xingge[10]=”這個星座出生的人崇尚自由、無拘無束及追求速度的感覺,”; xingge[11]=”就像是只走在高山絕壁的山羊一樣穩健踏實,”; out.print(“html”); out.print(“body bgcolor=#3300ff”); out.print(“center”); if(zuida[month-1]day) { err=true; }; if(day= fenjie[month-1]) { xingzuonumber=(month%12)+1; }else{xingzuonumber=month;}; if (err) { out.print(“您輸入的生日有錯誤,請重新輸入”); }else{ out.print(“table border=1″+”tr”); out.print(“td”); out.print(“img src = ‘image/”+ xingzuonumber + “.jpg’/td”); out.print(“td”); out.print(“您的生日是”+month+”月”+day+”日”+”您的星座是”+xingzuo[(xingzuonumber+10)%12]+”這個星座的特點是:”+xingge[(xingzuonumber+10)%12]+”font color=reda href = xingzuo.jsp點擊返回首頁”); } //out.print(xingzuo[0]); out.print(“/tr/table/center”); out.print(“/body”); out.print(“/html”); } }
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/156546.html