javascript取值并自动输出成文本【求助】 本帖最后由 yienzhu 于 2011-10-05 01:19:06 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 忘记说明输出的地方了<!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> 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> 非常感谢您的回复,有个小问题,“<label id='date'></label>天”这里的输出有点问题。输出的天数应该是充值卡所显示的天数,例如是包月卡就显示30天这样子。 <!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> 您好,代碼在firefox下失效,有解決辦法嗎?先謝了~~~ 把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> js png透明问题 lhgdialog的皮肤问题 jQuery用mouseover鼠标移动上去不能停止轮换,求助! 读取年,月,日,动态加载至下拉列表框,天数随年份,月份改变,求简便方法 #parse("/layouts/top.html")这段代码表示什么? 同样的数组同样方法排序结果却不一样 求一个js弹出新层并查询数据返回值的代码 函数嵌套问题 怎么美化javascript的弹出警告窗口? ui-router的 templateUrl 函数返回模板地址报错 JavaScript代碼在firefox下失效 请助:更改脚本,自主刷新时间设定
<!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>
<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>
<!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>
<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>