2013年6月17日 星期一

form option generate script

jqDataOption is a jQuery plugin that can help you to simplely generate HTML form option object like radio,checkbox,select and format them as a buttonSet or not. It can also generate serial option.
Let's see demo.

json:

[{"id":"1","value":"Apple"}
,{"id":"2","value":"Banana"}
,{"id":"3","value":"Lemon"}
,{"id":"4","value":"Melon"}]

generate checkbox or radio

$("#options").dataOption({
 datasource:json
 ,init:
 ,optionType:
 ,buttonSet:
});

options

serial generate

$("#inits").dataOption({optionType:"checkbox",buttonSet:false
 ,init:[2,3]
 ,options:{start:1 ,genDatasource:4}});

generate select

$("#optionType").dataOption({
 datasource:[{id:"checkbox",value:"checkbox"}
  ,{id:"radio",value:"radio"}]});
$("#buttonSet").dataOption({
  datasource:[{id:"true",value:"true"}
  ,{id:"false",value:"false"}]});
download jqDataOption

沒有留言:

張貼留言