本帖最后由 yienzhu 于 2011-10-05 01:19:06 编辑

解决方案 »

  1.   

    忘记说明输出的地方了
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
    <head>
    </head>
    <html>
        <head>
            <title>test</title>
        </head>
        <body>
        <select name='us_p' id="us_p">
            <option value='10'>包月卡(30天)</option>
            <option value='30'>季度卡(90天)</option>
            <option value='60'>半年卡(180天)</option>
            <option value='100'>包年卡(365天)</option>
        </select>
        連接數
        <select name='goods_count' id="goods_count">
            <option value='1'>1</option>
            <option value='2'>2</option>
            <option value='3'>3</option>
            <option value='4'>4</option>
            <option value='5'>5</option>
            <option value='6'>6</option>
            <option value='7'>7</option>
            <option value='8'>8</option>
            <option value='9'>9</option>
            <option value='10'>10</option>
        </select>個
    总价:<span id="total"></span>
    <p>
    您的使用时长将被延长<1要输出的地方>天,您可以同时使用<2要输出的地方>个设备连接。
        </body>
        <script language="JavaScript"> 
    window.onload = function(){
        var p = document.getElementById('us_p');
        var c = document.getElementById('goods_count');
        var t = document.getElementById('total');
        t.innerHTML = Math.round(parseFloat(p.options[p.selectedIndex].value, 10) * parseFloat(c.options[c.selectedIndex].value, 10) * 100) /100;
        p.onchange = c.onchange = function(){
            var p = document.getElementById('us_p');
            var c = document.getElementById('goods_count');
            var t = document.getElementById('total');
            t.innerHTML = Math.round(parseFloat(p.options[p.selectedIndex].value, 10) * parseFloat(c.options[c.selectedIndex].value, 10) * 100) /100;
        }
    }
    </script>
    </html>
      

  2.   

    lz先学好js基础再写。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
    <head>
    </head>
    <html>
        <head>
            <title>test</title>
        </head>
        <body>
        <select name='us_p' id="us_p">
            <option value='10'>包月卡(30天)</option>
            <option value='30'>季度卡(90天)</option>
            <option value='60'>半年卡(180天)</option>
            <option value='100'>包年卡(365天)</option>
        </select>
        連接數
        <select name='goods_count' id="goods_count">
            <option value='1'>1</option>
            <option value='2'>2</option>
            <option value='3'>3</option>
            <option value='4'>4</option>
            <option value='5'>5</option>
            <option value='6'>6</option>
            <option value='7'>7</option>
            <option value='8'>8</option>
            <option value='9'>9</option>
            <option value='10'>10</option>
        </select>個
    总价:<span id="total"></span>
    <p>
    您的使用时长将被延长<label id='date'></label>天,您可以同时使用<label id='count'></label>个设备连接。
        </body>
        <script language="JavaScript"> 
    window.onload = function(){
        var p = document.getElementById('us_p');
        var c = document.getElementById('goods_count');
        var t = document.getElementById('total');
     //   t.innerHTML = Math.round(parseFloat(p.options[p.selectedIndex].value, 10) * parseFloat(c.options[c.selectedIndex].value, 10) * 100) /100;
        p.onchange = c.onchange = function(){
    //    不用再定义
        //    var p = document.getElementById('us_p');
        //    var c = document.getElementById('goods_count');
        //    var t = document.getElementById('total');
            t.innerHTML = Math.round(parseFloat(p.options[p.selectedIndex].value, 10) * parseFloat(c.options[c.selectedIndex].value, 10) * 100) /100; document.getElementById('date').innerText = parseFloat(p.options[p.selectedIndex].value, 10);
    document.getElementById('count').innerText = c.options[c.selectedIndex].value;
        } //这样初始化更好点吧
    p.onchange();
    c.onchange();
    }
    </script>
    </html>
      

  3.   

    非常感谢您的回复,有个小问题,“<label id='date'></label>天”这里的输出有点问题。输出的天数应该是充值卡所显示的天数,例如是包月卡就显示30天这样子。
      

  4.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
    <head>
    </head>
    <html>
        <head>
            <title>test</title>
        </head>
        <body>
        <select name='us_p' id="us_p">
            <option value='10'>包月卡(30天)</option>
            <option value='30'>季度卡(90天)</option>
            <option value='60'>半年卡(180天)</option>
            <option value='100'>包年卡(365天)</option>
        </select>
        連接數
        <select name='goods_count' id="goods_count">
            <option value='1'>1</option>
            <option value='2'>2</option>
            <option value='3'>3</option>
            <option value='4'>4</option>
            <option value='5'>5</option>
            <option value='6'>6</option>
            <option value='7'>7</option>
            <option value='8'>8</option>
            <option value='9'>9</option>
            <option value='10'>10</option>
        </select>個
    总价:<span id="total"></span>
    <p>
    您的使用时长将被延长<label id='date'></label>天,您可以同时使用<label id='count'></label>个设备连接。
        </body>
        <script language="JavaScript"> 
    window.onload = function(){
        var p = document.getElementById('us_p');
        var c = document.getElementById('goods_count');
        var t = document.getElementById('total');
     //   t.innerHTML = Math.round(parseFloat(p.options[p.selectedIndex].value, 10) * parseFloat(c.options[c.selectedIndex].value, 10) * 100) /100;
        p.onchange = c.onchange = function(){
        //    不用再定义
        //    var p = document.getElementById('us_p');
        //    var c = document.getElementById('goods_count');
        //    var t = document.getElementById('total');
            t.innerHTML = Math.round(parseFloat(p.options[p.selectedIndex].value, 10) * parseFloat(c.options[c.selectedIndex].value, 10) * 100) /100;
        //要求没看清楚,这行改下吧
            document.getElementById('date').innerText = p.options[p.selectedIndex].innerText.match(/\d+/);
            document.getElementById('count').innerText = c.options[c.selectedIndex].value;
        }    //这样初始化更好点吧
        p.onchange();
        c.onchange();
    }
    </script>
    </html>
      

  5.   

    您好,代碼在firefox下失效,有解決辦法嗎?先謝了~~~
      

  6.   

    把innerText换成innerHTML , firefox下没有innerText属性<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
    <head>
    </head>
    <html>
        <head>
            <title>test</title>
        </head>
        <body>
        <select name='us_p' id="us_p">
            <option value='10'>包月卡(30天)</option>
            <option value='30'>季度卡(90天)</option>
            <option value='60'>半年卡(180天)</option>
            <option value='100'>包年卡(365天)</option>
        </select>
        連接數
        <select name='goods_count' id="goods_count">
            <option value='1'>1</option>
            <option value='2'>2</option>
            <option value='3'>3</option>
            <option value='4'>4</option>
            <option value='5'>5</option>
            <option value='6'>6</option>
            <option value='7'>7</option>
            <option value='8'>8</option>
            <option value='9'>9</option>
            <option value='10'>10</option>
        </select>個
    总价:<span id="total"></span>
    <p>
    您的使用时长将被延长<label id='date'></label>天,您可以同时使用<label id='count'></label>个设备连接。
        </body>
        <script language="JavaScript"> 
    window.onload = function(){
        var p = document.getElementById('us_p');
        var c = document.getElementById('goods_count');
        var t = document.getElementById('total'); //   t.innerHTML = Math.round(parseFloat(p.options[p.selectedIndex].value, 10) * parseFloat(c.options[c.selectedIndex].value, 10) * 100) /100;
        p.onchange = c.onchange = function(){
        //    不用再定义
        //    var p = document.getElementById('us_p');
        //    var c = document.getElementById('goods_count');
        //    var t = document.getElementById('total');
            t.innerHTML = Math.round(parseFloat(p.options[p.selectedIndex].value, 10) * parseFloat(c.options[c.selectedIndex].value, 10) * 100) /100;
        //要求没看清楚,这行改下吧
            document.getElementById('date').innerHTML = p.options[p.selectedIndex].innerHTML.match(/\d+/);
            document.getElementById('count').innerHTML = c.options[c.selectedIndex].value;
        }    //这样初始化更好点吧
        p.onchange();
        c.onchange();
    }
    </script>
    </html>