javascript - 如何将文本添加到表单输入

标签 javascript forms

我已经有了一个成熟的 JavaScript 表单。我所需要的只是一个简单的标签,哈哈。

它使用了之前的代码,但希望这个片段将有助于了解发生了什么:

export default class NewEvent extends FormStep {

    get inputs() {
        return [{
            name: 'department',
            label: 'Department / Specific Ministry'
        }, {
            name: 'title'
        }, {
            name: 'description',
            type: 'textarea'
        }, {
            name: 'checkboxApproved',
            type: 'checkbox',
            label: 'This copy is approved and is to be used as written.'
        }, {
            name: 'checkboxDetails',
            type: 'checkbox',
            label: 'These are the details! Please help me write a catchy description.'
        }, {
            name: 'location'
        }, {
            name: 'contactName',
            label: 'Event Contact Name'
        }, {
            name: 'contactEmail',
            label: 'Event Contact Email (required)'
        }, {
            name: 'contactPhone',
            label: 'Event Contact Phone (optional)'
        }, {
            name: 'eventURL'
        }, {
            name: 'isNewHRock',
            type: 'checkbox',
            label: 'This event is a new event we\'ve never done at HRock.'
        }, {
            name: 'hasOccurred',
            type: 'checkbox',
            label: 'We\'ve had this event before, but it is not on a recurring schedule.'
        }, {
            name: 'needsRegistration',
            type: 'checkbox',
            label: 'We need to set up registration for this event.'
        }, <EventPrice key = 'eventPrice' /> , <EventClassInfo key = 'eventClassInfo' /> , <EventDateTimeInfo key = 'eventDateTimeInfo' /> ]
    }
}

无论如何,所有这些项目都显示为表单。正如他们应该的那样。但我想简单地在复选框之间添加一个标签。我创建了以下 screenshot我想补充的内容。

enter image description here

但是,到目前为止,每当我在其中添加 text 时,它都会破坏代码,或者它会显示在 textfield 中...

帮忙?

最佳答案

这是一个“输入”对象。解析该对象的函数正在用它创建所有输入,这就是为什么你会得到一个文本框。我认为这不是代码中执行此操作的正确位置。

关于javascript - 如何将文本添加到表单输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32596520/

相关文章:

javascript - jQuery 插件创作 - 为不同的元素设置不同的选项

javascript - 如何从我的网站禁用(查看源代码)和(Ctrl + C)

forms - HTML 表单 "placeholder"在 IE 8 中不工作

javascript - 如何从 onSubmit 事件中获取表单的名称?

php - Joomla 表单创建

javascript - 一次只能以不同的形式选中一个单选按钮

javascript - 您无权调用 AppendRow

javascript - 在 IE10 和 IE 11 中,大 div 上的 Transform 属性翻译 3d 非常慢

javascript - JQuery获取formaction和formmethod

JavaScript 图像 OnLoad 事件