ESP32 Web Server Paging PROBLEM

piano1111
Posts: 4
Joined: Sat Apr 08, 2023 1:08 am

ESP32 Web Server Paging PROBLEM

Postby piano1111 » Tue Jun 27, 2023 12:59 am

I have a ESP32 running a Web Server controlled by an IPAD.
On the IPAD I have a list of 500 hyperlinks in a column
example item name 1 is associated with 192.168.1.100/1
item name 2 is associated with 192.168.1.100/2 etc.

Each page displays 50 item names. When I select an item name the server refreshes the list
starting with item name 1.

Is there a way that if I select item name 225 that when the server refreshes the page
it jumps to page 5, not to the beginning of the list?

It's easy to calculate the page by using the ip address returned back to the server 192.168.1.100/????, but how do I get the server program to automatically scroll down to page 5.

I'm looking for a simple solution without having to completely rewrite my code.

tanmanh0707
Posts: 15
Joined: Fri Jun 23, 2023 3:26 am

Re: ESP32 Web Server Paging PROBLEM

Postby tanmanh0707 » Tue Jun 27, 2023 5:06 pm

Simply get the item number from the request arguments, convert it to a number using toInt, then calculate the page index, note that your page index starts from 1

Code: Select all

#define ITEM_NUM_PER_PAGE 50
String itemNumber = getRequestArgument(); // this is your function to get the string "225"
int pageIndex = (itemNumber.toInt() / ITEM_NUM_PER_PAGE) + 1; //expected result is 5

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32 Web Server Paging PROBLEM

Postby lbernstone » Tue Jun 27, 2023 6:46 pm

This is purely a function of the html code you are supplying. I'm sure you have seen web pages using urls with the # in them to go to a specific point in the page.
https://www.w3docs.com/snippets/html/ho ... -page.html

piano1111
Posts: 4
Joined: Sat Apr 08, 2023 1:08 am

Re: ESP32 Web Server Paging PROBLEM

Postby piano1111 » Thu Jun 29, 2023 5:38 am

Hi Tanmanh0707
Once I have the page index how do I jump to that page?

Hi lbernstone
Thanks I'll read up using ID tags

tanmanh0707
Posts: 15
Joined: Fri Jun 23, 2023 3:26 am

Re: ESP32 Web Server Paging PROBLEM

Postby tanmanh0707 » Sat Jul 01, 2023 12:58 am

piano1111 wrote:
Thu Jun 29, 2023 5:38 am
Hi Tanmanh0707
Once I have the page index how do I jump to that page?
Do you want to display all 500 items and then scroll down to page 5, or do you want to display only page 5?

Who is online

Users browsing this forum: No registered users and 49 guests