即將推出的JavaScript,所以請好。 我的網站上有一個類型的quizz。我需要循環選中的單選按鈕並在用戶單擊提交時添加值。通過單選按鈕循環並加起來總計javascript
將值加起來後,必須出現一個小彈出窗口,顯示結果。如果單選按鈕的總價值是0-10顯示味精1 否則之間,如果單選按鈕的總價值爲11-20 diplay味精2 其他顯示味精3
我已經在網上搜索,但我只是不能找到一個之間如何遍歷單選按鈕,並添加了總計簡單的工作說明
我的HTML形式如下
你幾歲?
18-21
22-30
30-42
你怎麼看怎麼樣?
我類似於泰國
我是一個sterotypical外國人(白皮膚,金黃色的頭髮,藍色的眼睛)
我
我老了一個女孩
你是什麼資格 的水平
高中
大專文憑/證書
大學
碩士或更高
<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>
第二個問題似乎缺少一些選項。 –