Public Library-study Note 2

Source: Internet
Author: User

1. display controller variables in the view.

Assign a value to the variable in the control, such as $ this-> info_user = $ user, which can be directly used in the view.

2. Use the volist tag for HTML display Arrays

<Volist name = "info_user" id = "VO">

{$ VO. Username} {$ VO. Email} can use the key-value pairs in the array.

3. Hide button <button type = "Submit" style = "display: none"> submit changes </button>

4. Add JS Code to view HTML. Note that the introduction of JS Code must be declared in the head label!

<block name="head">    <script type="text/javascript">        function writable(){            alert("5");        }    </script></block>

Or

<block name="head">   <script type="text/javascript" src="/Public/js/Contribute/index.js"></script></block>

In this way, functions in javascript can be used.

5. Use JavaScript Functions to modify the readonly attribute of HTML tags.

VaR username = Document. getelementsbyid ("1 ");
Username. readonly = "";

// Set the submit button to visible display: None --> display: inline or default
VaR submit = Document. getelementsbyname ("Submit ");
Submit [0]. style. Display = ""; visible in inline by default

6. Differences between getelementsbyname and getelementbyid:

VaR username = Document. getelementsbyname ("username"); obtain multiple objects named username and the result is an array. Modify the attributes in the username [I] mode during use;

VaR username = Document. getelementsbyid ("1"); get a specific object. Use it directly.

7. Jump to the page

$ This-> success ('Modified successfully', '/user/userinfo ');

$ This-> error ('modification failed', '/user/userinfo ');

8. update the database using the data submitted by post

// If it is not submitted by post, an error is reported directly.
If (! Is_post) Halt ("the page does not exist ");

// Write the modified personal information to the database
$ User = D ("user ");

$ Id = SESSION ('user') ['id'];
$ Where ['id'] = $ ID;

// Use arrays to modify the database

$ Data ['email '] = I ('Post. address ');
$ Data ['telphone'] = I ('Post. telphone ');

$ Data ['last _ login_ip '] = I ('Post. last_login_ip ');

$ User-> where ($ where)-> Save ($ data );

 

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.