日期:2014-05-16 浏览次数:20324 次
<form name="f1">
<p><h3>Ticket type:</h3></p>
<p><input type="radio" name="r1" value="50" >Admission to the conference only</p>
<p><input type="radio" name="r1" value="75"/>Admission to the conference and exhibition</p>
<p><input type="radio" name="r1" value="100"/>Admission to the conference, exhibition and all screenings</p>
</form>
<form name="f3">
<p><h3>Delegate type:</h3></p>
<p><input type="radio" name="r3" onclick="fn1()" id="r31" value="2" >General attendee</p>
<p><input type="radio" name="r3" onclick="fn1()" id="r32" value="1.5"/>Presenter</p>
<p><input type="radio" name="r3" onclick="fn1()" id="r33" value="1"/>Student</p>
</form>
<button onclick="Calculation()">Calculation</button>
<script>
var inputs=document.getElementsByTagName('input'),vs=[];
for(var i=0,L=inputs.length;i<L;i++)
inputs[i].onclick=function(){
vs[this.name=='r1'?0:1]=this.value
}
function Calculation(){
var error=['Ticket type','Delegate type']
if(!vs[0]) {
alert( 'Ticket type can not be empty');
}else if(!vs[0]) {
alert( 'Ticket type can not be empty');
}else
alert( vs[0]* vs[1])
}
</script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<