簡體   English   中英

如何使用javascript / jQuery生成動態表單?

[英]How to generate a dynamic form using javascript/jQuery?

我需要基於服務器的Ajax響應動態生成整個html表單。 作為響應,將提供諸如輸入類型,輸入標簽,驗證(如果有)等信息。

該表格最多將始終包含十個字段。

是否有任何jQuery / javascript工具/插件來生成表單?

謝謝。

編隊

從他們的例子:

    value = {"key":"value"} "key" will be the value attribute and "value" will be the shown value of the element. If the array is constructed like {"value",value","value"} (without keys) then the value attribute of the input will be an auto-incremented number starting from 0.
options = {} See options table below.

$.fn.formation(options); [Create a form]
$.formation.addInput(options); [Append an input]
$.formation.addSelect(values,options); [Append a select]
$.formation.addTextarea(options); [Append a textarea]
$.formation.addCheckboxes(values,options); [Append an unordered list of checkboxes]
$.formation.addRadios(values,options); [Append an unordered list of radio buttons]
$.formation.addCaptcha(options); [Adds a captcha question to your form]
$.formation.addButton(options); [Append a button]
$.formation.setErrorMessages(options); [Set custom error messages for validation]

但是,這是您可以輕松使用Jquery進行的所有操作,並且它是一種很好的學習體驗,因此我建議您自己嘗試。

暫無
暫無

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

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