![](/img/trans.png)
[英]How to set selected value of 's:radio' button in 's:textarea' with JavaScript?
[英]How can I multiply a value from a radio button by a number in Javascript and have the answer display in a textstring inside a textarea?
我需要將單選按鈕的user_input乘以一個整數。 user_input可以是1,2或3。我可以將單選按鈕的值拖入textarea,但是如何將其乘以某個值呢? 理想情況下,我需要textstring + ='Fee(£):'+(user_input)*'5'+'\\ n';
謝謝你的幫助!
// Get value of the 'Fee' radio buttons.
user_input = '';
for (i=0;i<document.forms['example'].fee.length;i++) {
if (document.forms['example'].fee[i].checked) {
user_input = document.forms['example'].fee[i].value;
}
}
textstring += 'Fee (£): ' + user_input + '\n';
// Write textstring to the textarea.
document.forms['example'].output.value = ("\n*** Thank You for your reservation***"+"\n")+ textstring + ("\n*** End of Form***"+"\n");
你有沒有嘗試過:
textstring += 'Fee (£): ' + (user_input*5) + '\n';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.