微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Populate <strong>Finally!</strong>

程序名称:Populate <strong>Finally!</strong>

授权协议: 未知

操作系统: 未知

开发语言:

Populate <strong>Finally!</strong> 介绍

Populate a form or an element’s child elements using a JSON object.

This plugin supports full PHP naming and deep data structures, as well as
checkBox arrays and other non-standard UI controls. The plugin can be used as
part of your AJAX toolkit, or for separating server-side code from HTML by
populating a form after the page has loaded eg:

$('form').populate({'text':'text', 'radio':1})

and not inline as the page is processed, such as:

<input type="text" name="text" id="text" value="<?PHP echo $text; ?>" /> <input type="radio" name="radio" id="radio-1" checked="<?PHP echo $val == 1; ?>" /> <input type="radio" name="radio" id="radio-2" checked="<?PHP echo $val == 2; ?>" />

Non-form elements

You can also populate non-form controls such as

s, by specifiying the id
and an identifying attribute (defaults to id):

$('div').populate({'text-1':'text', 'text-2':'More text'})

This can be useful when you want to show the results of a database call, but
don’t want the text to be editable.

Usage

Just include the PHP JSON class, PHP helper function and of course Populate at
the top of your page, and a PHP snippet such as this the bottom:

<?PHP populate('form', $data); ?/>

Which will output something meaningful like this:

$('form').populate({'text':'text', 'radio':1})

Live Demo

Finally!

I’ve Now FINALLY put up a full set of instructions and a working demo, with
examples of:

  • Populating a simple form, using string variable types for textfields, radiobuttons, dropdowns and checkBoxes
  • Populating a complex form, using array variable types for checkBox arrays and multi-list Boxes
  • Populating a hierarchical form, using hierarchical JSON data

View the jQuery Populate
Demo
here.

Download

JavaScript

PHP


Populate <strong>Finally!</strong> 官网

http://plugins.jquery.com/project/Populate

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐