|
蓝森林 http://www.lslnet.com 2006年8月25日 8:28
radio 数值累加问题
假设有一个框架页,分上下2部分,如何用js让处于上部分的多组 radio 单选的值累加显示在下部分的页面上。 |
up~ 在线等啊,谢谢拉! |
一种解法:
http://sheneyan.com/test/f/f.htm
文件1:f.htm
[code]
<frameset rows="50%,50%">
<frame src="2.htm"></frame>
<frame src="3.htm" name="aa"></frame>
</frameset>
[/code]
文件2:2.htm
[code]
<form action="3.htm" target="aa">
<fieldset>
<legend>1</legend>
<input onclick="this.form.submit()" type="radio" name="a1" value="1" id="a11"><label for="a11">1</label>
<input onclick="this.form.submit()" type="radio" name="a1" value="2" id="a12"><label for="a12">2</label>
<input onclick="this.form.submit()" type="radio" name="a1" value="3" id="a13"><label for="a13">3</label>
<input onclick="this.form.submit()" type="radio" name="a1" value="4" id="a14"><label for="a14">4</label>
<input onclick="this.form.submit()" type="radio" name="a1" value="5" id="a15"><label for="a15">5</label>
<input onclick="this.form.submit()" type="radio" name="a1" value="6" id="a16"><label for="a16">6</label>
<input onclick="this.form.submit()" type="radio" name="a1" value="7" id="a17"><label for="a17">7</label>
<input onclick="this.form.submit()" type="radio" name="a1" value="8" id="a18"><label for="a18">8</label>
<input onclick="this.form.submit()" type="radio" name="a1" value="9" id="a19"><label for="a19">9</label>
</fieldset>
<fieldset>
<legend>2</legend>
<input onclick="this.form.submit()" type="radio" name="a2" value="1" id="a21"><label for="a21">1</label>
<input onclick="this.form.submit()" type="radio" name="a2" value="2" id="a22"><label for="a22">2</label>
<input onclick="this.form.submit()" type="radio" name="a2" value="3" id="a23"><label for="a23">3</label>
<input onclick="this.form.submit()" type="radio" name="a2" value="4" id="a24"><label for="a24">4</label>
<input onclick="this.form.submit()" type="radio" name="a2" value="5" id="a25"><label for="a25">5</label>
<input onclick="this.form.submit()" type="radio" name="a2" value="6" id="a26"><label for="a26">6</label>
<input onclick="this.form.submit()" type="radio" name="a2" value="7" id="a27"><label for="a27">7</label>
<input onclick="this.form.submit()" type="radio" name="a2" value="8" id="a28"><label for="a28">8</label>
<input onclick="this.form.submit()" type="radio" name="a2" value="9" id="a29"><label for="a29">9</label>
</fieldset>
<fieldset>
<legend>3</legend>
<input onclick="this.form.submit()" type="radio" name="a3" value="1" id="a31"><label for="a31">1</label>
<input onclick="this.form.submit()" type="radio" name="a3" value="2" id="a32"><label for="a32">2</label>
<input onclick="this.form.submit()" type="radio" name="a3" value="3" id="a33"><label for="a33">3</label>
<input onclick="this.form.submit()" type="radio" name="a3" value="4" id="a34"><label for="a34">4</label>
<input onclick="this.form.submit()" type="radio" name="a3" value="5" id="a35"><label for="a35">5</label>
<input onclick="this.form.submit()" type="radio" name="a3" value="6" id="a36"><label for="a36">6</label>
<input onclick="this.form.submit()" type="radio" name="a3" value="7" id="a37"><label for="a37">7</label>
<input onclick="this.form.submit()" type="radio" name="a3" value="8" id="a38"><label for="a38">8</label>
<input onclick="this.form.submit()" type="radio" name="a3" value="9" id="a39"><label for="a39">9</label>
</fieldset>
</form>
[/code]
文件3:3.htm
[code]
count:
<script>
var t=location.search;
var r=/a\d+=\d+/gi
t=t.match(r);
var s=0;
try{
for (var i=0,c;c=t[i];i++)
s+=parseInt(c.match(/a\d+=(\d+)/i)[1],10)
}
catch(e){}
document.write(s)
</script>
[/code] |
thx! |
|