Number of items displayed per page

Source: Internet
Author: User
There is a paging issue in the process of improving the attendance system. When checking the attendance record, you can manually select how many records are displayed on each page. if it is specified that 10 records are displayed overnight

There is a paging issue in the process of improving the attendance system. Instructor Chen mentioned that when viewing attendance records, you can manually select how many records are displayed on each page. if it is specified that 10 records are displayed overnight, page turning is troublesome, therefore, we will solve the problem of manually selecting the pagesize of the page.

The list page is a drop-down box with 10, 20, and 40 entries displayed...

I have never done it before, but I think it should be very simple. just use jquery to upload the changed pagesize to the php page. It was discovered today that it is more difficult to start than to brainstorm!

The first idea is to change the value of the drop-down list, that is, the onchange event, and then pass the value to the system. But the problem arises: The pagesize passed in can be received in the php program, but 10 records are still displayed, which cannot be changed.

Then I thought, refresh the page after passing the value, and the window. location. reload () should be done. After adding this, it still does not work, because after refreshing, it returns to the original page, and the changed pagesize returns to the original 10, so I thought, how to keep the pagesize after refresh before the next onchange event.

Store the value unchanged. how can this problem be solved? After thinking about the session for a long time, I thought about the session. do not all the login information stored in the session during login? This is simple!

Therefore, the onchange event is directed to login. in the php file, write The pagesize in $ _ SESSION ['admin'] ['pagesize']. you can use it for paging and refresh it. After the modification, I tried it and found it successful!

To continue the test, there are two other minor issues: the default pagesize should be 10 when you return to the original list link after changing the pagesize, destroy the value after the pagination ends. unset ($ _ SESSION ['admin'] ['pagesize']). In addition, after the pagesize is changed, in the drop-down list, the current pagesize value is selected by default. Therefore, in the php program, The pagesize value is assigned to the template, and the if statement of smarty is used to determine whether the pagesize value is selected.

At this point, there should be no problem. Success!

Think about it afterwards. do not think that I should be able to do things in the future. if everything is done in person, I will be able to be sure. the other one is to be patient and implement things step by step, don't eat a fat man, or give up at will. when you succeed, the harvest and joy are really "nice "!

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.