求救,求javascript强人帮个忙。

  • l
    leoboy
    学校作业,计算邮件费用的,网页上javascript程序。
    实在是扛不住,有行的帮忙下,万分感谢。

    使用代码

    函数
    EVAL()
    VAR
    type="radio"
    (name="ABC"
    for
    document.….name.length
    document.….radiochecked
    if true or fause
    補足type="checkbox" 可以在name之间复数选择



    郵便料金システム
    重さ:50g以内 ¥120
    100以内 ¥140
    200以内 ¥220
    500以内 ¥390
    1kg以内 ¥580
    1kg以外 ¥850

    速達 500g以内 ¥270
    500以外 ¥370

    書留 現金書留 ¥420
    一般書留 ¥420
    簡易書留 ¥350

    完成后外观

    ーーーーーーーーーーーーーーーーー我が名は分割線ーーーーーーーーーーーーーーーーーーーーーーー


    重さ50g以内100以内200以内500以内1kg以内1kg以外
    件数[ ]件 半角
    速達◎是 ◎否
    書留◎現金書留 ◎一般書留 ◎簡易書留 ◎否

    [合計金額算出]<----计算按钮

    [ ]円


    ーーーーーーーーーーーーーーーーー我が名は分割線ーーーーーーーーーーーーーーーーーーーーーーー外观图
    http://pweb.cc.sophia.ac.jp/~b-li/TS.htm



    完成后外观


    [本帖最后由 leoboy 于 2008-1-15 16:49 编辑]
  • L
    LiquidM
    图看不到,另外这是javascript的题吧?貌似跟java不搭界啊
  • l
    leoboy
    我文盲了,是javascript的,呵呵。我上图。。。
  • l
    leoboy
    自己顶...
  • i
    iorilu
    这种东西网上多的是,lz是计算机专业吗,费点心google吧
  • c
    cc0128
    function getPriceByWeight(weight){
    if(weight<50){
    return 120;
    }
    if(weight<100){
    return 140;
    }
    if(weight<200){
    return 220;
    }
    if(weight<500){
    return 390;
    }

    }

    function getPriceByFast(weight){
    if(weight<500){
    return 270;
    }
    return 370;
    }

    function getPriceByBook(bookName){
    if("現金書留".equal (bookName)){
    return 420;
    }
    if("一般書留".equal (bookName)){
    return 420;
    }
    if("簡易書留".equal (bookName)){
    return 350;
    }
    }

    function getPrice(bookName,weight,isFast){
    var price=0;
    price=getPriceByWeight(weight)+getPriceByBook(bookName);
    if(isFast){
    price+=getPriceByFast(weight);
    }
    return price;
    }

    function check(){
    var bookName=self.document.getElementById("bookName").value;
    var weight=self.document.getElementById("weight").value;
    var isFast=false;
    if(self.document.getElementById("isFast").checked){
    isFast=ture;
    }

    var price=getPrice(bookName,weight,isFast);
    self.document.getElementById("price").value=price;
    }
  • l
    leonWong
    函数
    EVAL()
    VAR
    type="radio"
    (name="ABC")
    for
    document.….name.length
    document.….radiochecked
    if true or fause
    補足type="checkbox" 可以在name之间复数选择

    不知道这短是什么意思?

    [本帖最后由 leonWong 于 2008-1-15 16:38 编辑]
  • c
    cc0128
    我写完LZ又编辑了。。
    我是把重量,书本类型当成INPUT,快递当成checkbox写的
  • l
    leoboy
    我??文科的,这个是我们这学期计算机课的最后个作业。
    那些代码是老师要求我们用的~~

    六楼的大大,谢谢你,不过似乎不能用。
    这个是我们打的练习题。

    <html>
    <head>
    <script language="JavaScript">
    function fu(){
    for(i=0; i<document.form1.radio1.length; i++){
    if(document.form1.radio1.checked){
    a = document.form1.radio1.value
    }
    }
    document.form1.text2.value = a;
    }
    </script>
    </head>



    <body>
    <center>
    <form name="form1">
    <input type="radio" name="radio1" value=1 checked>1番目
    <input type="radio" name="radio1" value=2> 2番目
    <input type="radio" name="radio1" value=3> 3番目<br>
    <br>
    <input type="button" value="クリック" onclick="fu();"><br><br>
    <input type="text" name="text2" size="5">番目
    </form>
    </center>
    </body>
    </html>
  • l
    leoboy
    不要太高深了,老师一看就知道我是抄的了
    打在TXT里面最后可以存成网页,直接打开用。。。拜托了!!!

    [本帖最后由 leoboy 于 2008-1-15 16:44 编辑]
  • l
    leoboy
  • c
    cc0128
    <!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=gb2312" />
    <title>无标题文档</title>
    <script language="javascript">
    function cc(){
    var f1=self.document.getElementById("form1")
    var r0p=getCheckedValue(f1.radiobutton);
    var r1p=getCheckedValue(f1.radiobutton1);
    var r2p=getCheckedValue(f1.radiobutton2);
    var t1p=f1.textfield.value;
    f1.textfield2.value=(parseInt(r0p)+parseInt(r1p)+parseInt(r2p))*parseInt(t1p);
    }
    function getCheckedValue(rdo){
    for(var i=0;i<rdo.length;i++){
    if(rdo.checked){
    return rdo.value;
    }
    }
    }

    </script>
    </head>


    <body>
    <form id="form1" name="form1" method="post" action="">
    <p>
    <input type="radio" name="radiobutton" value="120" />
    50
    <input type="radio" name="radiobutton" value="140" />
    100
    <input type="radio" name="radiobutton" value="220" />
    200
    <input type="radio" name="radiobutton" value="390" />
    500
    <input type="radio" name="radiobutton" value="580" />
    1000
    <input type="radio" name="radiobutton" value="850" />
    1000+</p>
    <p>
    <input type="text" name="textfield" />
    件 </p>
    <p>
    <input type="radio" name="radiobutton1" value="270" />

    <input type="radio" name="radiobutton1" value="370" />

    </p>
    <p>
    <input type="radio" name="radiobutton2" value="420" />
    现金
    <input type="radio" name="radiobutton2" value="420" />
    一般
    <input type="radio" name="radiobutton2" value="350" />
    简易
    <input type="radio" name="radiobutton2" value="0" />
    否 </p>
    <p>
    <input type="button" name="btn" value="按钮" onclick="cc()"/>
    </p>
    <p>
    <input type="text" name="textfield2" />
    </p>
    </form>
    <p> </p>
    </body>
    </html>
  • L
    LiquidM
    <html>
    <head>
    <script language="JavaScript">
    function sum(){ var a=0

    for(i=0; i<document.form1.weight.length; i++){
    if(document.form1.weight.checked==true){
    a = eval(document.form1.weight.value)
    }
    }


    a=a*eval(document.form1.quantity.value)
    for(i=0; i<document.form1.fast.length; i++){
    if(document.form1.fast.checked==true){
    a = a+eval(document.form1.fast.value)
    }
    }

    for(i=0; i<document.form1.book.length; i++){
    if(document.form1.book.checked==true){
    a = a+eval(document.form1.book.value)
    }
    }

    document.form1.text2.value = a;
    }
    </script>
    </head>



    <body>
    <center>
    <form name="form1">
    <input type="radio" name="weight" value=120 checked>50g以内
    <input type="radio" name="weight" value=140> 100g以内
    <input type="radio" name="weight" value=220> 200g以内<br>
    <input type="radio" name="weight" value=390> 500g以内
    <input type="radio" name="weight" value=580> 1kg以内
    <input type="radio" name="weight" value=850> 1kg以外
    <br><br>
    件数
    <input type="text" name="quantity" value="1">
    <br><br>
    <input type="radio" name="fast" value=0 checked> 否
    <input type="radio" name="fast" value=270> 500g以内
    <input type="radio" name="fast" value=370> 500g以外
    <br><br>
    <input type="radio" name="book" value=420 checked> 現金書留
    <input type="radio" name="book" value=420> 一般書留
    <input type="radio" name="book" value=350> 簡易書留


    <input type="button" value="クリック" onclick="sum();"><br><br>
    <input type="text" name="text2" size="5">金
    </form>
    </center>
    </body>
    </html>
  • l
    leonWong
    我的里面怎么有CSS?
  • 7
    788414
    同道真多啊.....