簡體   English   中英

如何將單選按鈕的值乘以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 (&#163;): ' + 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 (&#163;): ' + (user_input*5) + '\n';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM