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.
ESP32 Web Server Paging PROBLEM
-
- Posts: 15
- Joined: Fri Jun 23, 2023 3:26 am
Re: ESP32 Web Server Paging PROBLEM
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
-
- Posts: 826
- Joined: Mon Jul 22, 2019 3:20 pm
Re: ESP32 Web Server Paging PROBLEM
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
https://www.w3docs.com/snippets/html/ho ... -page.html
Re: ESP32 Web Server Paging PROBLEM
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
Once I have the page index how do I jump to that page?
Hi lbernstone
Thanks I'll read up using ID tags
-
- Posts: 15
- Joined: Fri Jun 23, 2023 3:26 am
Who is online
Users browsing this forum: No registered users and 65 guests