我是 javascript 新手,所以请善待。我的网站上有一种测验。我需要遍历选中的单选按钮并在用户单击提交时添加值。
将值相加后,必须出现一个小的弹出窗口来显示结果。如果单选按钮的总值在 0-10 之间显示消息 1 否则如果单选按钮的总值在 11-20 之间显示消息 2 否则显示消息 3
我已经搜索了互联网,但我只是找不到关于如何循环通过单选按钮并加起来的简单工作解释
我的 HTML 表单看起来像这样
你今年多大?
18-21
22-30
30-42
42
你长什么样?
我看起来像泰国
人 我是典型的外国人(白皮肤、金发、蓝眼睛)
我是女孩
我年纪大了
你的学历是多少
高中
大学文凭/证书
学士学位
硕士学位或更高
<strong>From which country are you?</strong><br />
<input type="radio" value="3" name="country" />Aus, NZ, SA, UK, US<br />
<input type="radio" value="0" name="country" />Other country from the once listed above<br />
<br />
<strong>Is English your naitive language</strong><br />
<input type="radio" value="2" name="country" />yes<br />
<input type="radio" value="0" name="country" />no<br />
<input type="radio" value="1" name="country" />no, but I am fluent<br />
<br />
<strong>Do you have any experience in teaching English in Thailand?</strong>
<br />
<input type="radio" value="0" name="experience" />none<br />
<input type="radio" value="1" name="experience" />0-1 year<br />
<input type="radio" value="3" name="experience" />1-2 years<br />
<input type="radio" value="4" name="experience" />2 years +<br />
<br />
<strong>What is your knowledge of Thai language and Thai culture</strong>
<br />
<input type="radio" value="1" name="culture" />I know nothing<br />
<input type="radio" value="2" name="culture" />I know my basics<br />
<input type="radio" value="3" name="culture" />I know slightly more than the basics<br />
<input type="radio" value="4" name="culture \ " />My friends say I am Thai<br />
<br />
<strong>What is your knowledge of Thai language and Thai culture</strong>
<br />
<input type="radio" value="1" />I know nothing<br />
<input type="radio" value="2" />I know my basics<br />
<input type="radio" value="3" />I know slightly more than the basics<br />
<input type="radio" value="4" />My friends say I am Thai<br />
<br />
<strong>Do you have any visible tatoos or piercings?</strong>
<br />
<input type="radio" value="2" />Yes but it is not visible<br />
<input type="radio" value="4" />none<br />
<input type="radio" value="0" />Visible tatoo or piercing<br />
<br />
<strong>What gender are you</strong>
<br />
<input type="radio" value="1" />Male<br />
<input type="radio" value="4" />Female<br />
<br />
<input type="submit" onclick="showTotal" />
</form>