"PHP additions and Deletions Instance" section 21st-User modification function

Source: Internet
Author: User

19.1 Adding user-Modified buttons

Open the usermanage.html and find the place to add the button:

It's easy to see that the Edit button should be on the right side of the new user.

So, if I am a new person, I am not familiar with the project itself, then I have to find this page, and then go to the corresponding page to find the New button, and then add the corresponding code to the right of the new button. Code How to write, I do not care, the first thing is to find out where this page.

Method: Right click on this page to view the frame source code

This usermanage.html is the address of the webpage.

Open Usermanage.html,ctrl + F and search for new user characters.

Found this place, you can find that the original, the New button is a label, so, we follow the gourd painting scoop.

This way, compared to the previous code, make a change, the new User's button, the binding function name changed to Openadddialog.

Function code:

//打开新增窗口function openAddDialog(){        $("#dialog0").dialog("setTitle","新增用户").dialog("open");}//打开修改窗口function openModifyDialog(){    $("#dialog0").dialog("setTitle","编辑用户").dialog("open");}

Let's take a look at the Save method:

Found a problem before the save, because only new, so is not with the ID. Well, if we now ask that this save method be either new or modified. You need to dynamically change the URL.

Added: url = save.php
Modified:: url = save.php?id=xxx
Code:

var url = null;//打开新增窗口function openAddDialog(){    url = "save.php";    $("#dialog0").dialog("setTitle","新增用户").dialog("open");}//打开修改窗口function openModifyDialog(){    //编辑用户的时候,只允许用户勾选一条数据    var rows = $("#grid0").datagrid("getSelections");    if(rows.length != 1){        $.messager.alert("系统提示","请勾选一条数据!");        return;    }    //将勾选的数据填充到窗口中    $("#form0").form("load",rows[0]);    url = "save.php?id=" + rows[0].id;    $("#dialog0").dialog("setTitle","编辑用户").dialog("open");    }

Open the save.php and add the following code:

Note that because the ID is stitched behind the URL, so is the get way, need to use $_get to accept, can not use $_post.

SOURCE Access: HTTPS://WWW.JIANSHU.COM/P/4977BD0073D5

"PHP additions and Deletions Instance" section 21st-User modification function

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.