Page 1 of 1

ESP32 Web Server Paging PROBLEM

Posted: Tue Jun 27, 2023 12:59 am
by piano1111
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.

Re: ESP32 Web Server Paging PROBLEM

Posted: Tue Jun 27, 2023 5:06 pm
by tanmanh0707
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

Re: ESP32 Web Server Paging PROBLEM

Posted: Tue Jun 27, 2023 6:46 pm
by lbernstone
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

Re: ESP32 Web Server Paging PROBLEM

Posted: Thu Jun 29, 2023 5:38 am
by piano1111
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

Re: ESP32 Web Server Paging PROBLEM

Posted: Sat Jul 01, 2023 12:58 am
by tanmanh0707
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?