html单选传值,将单选按钮值从html页面传递给html。

这篇博客探讨了在HTML页面中如何实现单选按钮的值传递和计算。作者在创建一个安全评估网页时遇到问题,需要在多个HTML页面间传递用户选择,并在用户提交答案后计算'是'的回答数量。通过JavaScript脚本,实现了当单选按钮改变时更新总分,并在用户点击提交后展示通过或未通过评估的提示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我正在使用HTML和Java脚本的新安全评估网页。出于某种原因,代码无法正常工作,无法获得理想的结果。代码应该工作的方式是让用户回答是或否问题,然后将值传递到整个5个HTML页面,直到用户单击提交时的最后一页为止。然后页面将显示回答为yes的问题数量。将单选按钮值从html页面传递给html。

任何帮助将不胜感激。

感谢,

$('.calc').change(function() {

calcscore();

});

$('#submitted').click(function() {

sumInputs();

result();

});

function sumInputs() {

var inputs = $('.calc:checked'),

result = $('#total').val(),

sum = 0;

for (var i = 0; i < inputs.length; i++) {

sum += parseInt(inputs[i].value);

}

$('#total').val(sum);

}

function calcscore() {

var score = 0;

$('.calc:checked').each(function() {

score += parseInt($(this).val(), 10);

});

$('#total').val(score);

}

-------------------------------------------------

(Last java script code)

$('.calc').change(function() {

calcscore();

});

$('#submitted').click(function() {

sumInputs();

result();

});

function sumInputs() {

var inputs = $('.calc:checked'),

result = $('#total').val(),

sum = 0;

for (var i = 0; i < inputs.length; i++) {

sum += parseInt(inputs[i].value);

}

$('#total').val(sum);

}

function result() {

var text;

var score = (($('#total').val())/57) * 100;

var score = score.toFixed(1);

if (score < 60) {

alert (text = "Total score " + score + ": You have failed the Assessment");

}

else {

alert (text = "Total score " + score + ": You have passed the Assessment");

}

$('#demo').text(text);

}

function calcscore() {

var score = 0;

$('.calc:checked').each(function() {

score += parseInt($(this).val(), 10);

});

$('#total').val(score);

}

\t \t

7. Do you have policies and procedures that address allowing authorized and

limiting unauthorized physical access to electronic information systems and the

facilities in which they are housed?

Yes

No

N/A

8. Do your policies and procedures specify the methods used to control physical

access to your secure areas, such as door locks, access control systems,

security officers, or video monitoring?

Yes

No

N/A

---------------------------------------

Last html Page

COMPLIANCE AND AUDIT

<

54. Do you review and revise your security documents, such as: policies,

standards, procedures, and guidelines, on a regular basis?

Yes

No

N/A

55. Do you audit your processes and procedures for compliance with established

policies and standards?

Yes

No

N/A

56. Do you test your disaster plans on a regular basis?

Yes

No

N/A

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值