YII Ajax Update Data

Source: Internet
Author: User
1. Set as input box, enter and modify in the list

Set a onchange event for TimeLimit

' Columns ' =>array ('        id ',        array (' name ' = = ' platform ', ' value ' = ' $data->platform '),        Array (' Name ' = = ' version ', ' value ' = ' $data->version '),        Array (' name ' = = ' build ', ' value ' = ' $data Build '),        Array (' name ' = = ' uptime ', ' value ' = ' $data->uptime '), Array (' name ' = ' = ' timelimit ', ' type ' = > ' raw ',//Input box ' value ' = ' Chtml::textfield ' ("TimeLimit", $data->timelimit,array ("size"  = 25,//border-sized " Class "=" Txt_timelimit ",//Set style" id "    =" $data->id ",//Current Data ID" onchange "+"  Checkedfield ( This.value, $data->id,1) ",)))
Upload data to the background for updates
Update function Checkedfield (val,id,flag) {Updateapp (id,val,flag);}
function Updateapp (id,val,flag) {if (Confirm ("Confirm modification? ") {$.ajax ({url: ' Updateapp ', type: ' POST ', data:{" id ": ID," val ": Val," flag ": Flag},datatype: ' JSON ', success:function ( JSON) {//successfully obtained is also a JSON object if (json.flag) {alert ("modified successfully") $ (this). Val (json.val); Window.location.reload ();}})}}
Ii. operation of a checkbox

Add the following code under columns

Array (' name ' = ' isblock ', ' type ' = ' raw ',//Input box ' value ' = ' Chtml::checkbox ' ("Isblock", $data->isblock, Array ("id"    = "$data->id",//Current Data id "value" = "$data->isblock", "onchange"  = "  check_ Isblock (this.checked, $data->id,3) ",)),

Set the default selected check box with JS
CheckBox Default Check Event $ (document). Ready (function () {var checkboxs = document.getelementsbyname ("Isblock"); for (Var i=0;i
 
  
  
   
Finally, the data is uploaded to the backstage
function Check_isblock (ischeck,id,flag) {var val = ischeck? ' Y ': ' N ';//updateapp (Id,val,flag);}


The above describes the Yii Ajax update data, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.