Javascript 使用单选按钮作为功能的主要触发器,该功能根据选项显示字段并接受输入

Javascript 使用单选按钮作为功能的主要触发器,该功能根据选项显示字段并接受输入,javascript,string,radio-button,Javascript,String,Radio Button,我有一个工作应用程序,其中有一组字段,用户在其中输入信息,并在文本文件中进行处理和打印。我现在需要添加一个定制的动态特性。使用单选按钮,用户将选择要输入的输入类型。我无法用语法思考!我能想到要遵循的步骤,但在语法方面我一无所知 我知道我需要声明一个返回字符串的方法。 此方法根据“选中”单选按钮进行操作 选中时,我应该使用DOM将新字段附加到div。 然后用户将输入我将存储的值,并与其他固定字符串连接 <input type="radio" id="blue&

我有一个工作应用程序,其中有一组字段,用户在其中输入信息,并在文本文件中进行处理和打印。我现在需要添加一个定制的动态特性。使用单选按钮,用户将选择要输入的输入类型。我无法用语法思考!我能想到要遵循的步骤,但在语法方面我一无所知

我知道我需要声明一个返回字符串的方法。 此方法根据“选中”单选按钮进行操作 选中时,我应该使用DOM将新字段附加到div。 然后用户将输入我将存储的值,并与其他固定字符串连接

 <input type="radio" id="blue" name="ISP" value="blue" checked="checked">
                <label for="Blue">Blue</label>    
                <input type="radio" id="red" name="ISP" value="red">    
                <label for="red">Red</label>
                <input type="radio" id="yellow" name="ISP" value="yellow">    
                <label for="yellow">Yellow</label>
})

var line1 = "This is the first line"

var line2 !! the value for this one should be the return of a function that operates according to the selected radio button. 

var line3 = "This is the line after."

var total = line1 + line2 + line3
console.log(total);