Connecting Tech Pros Worldwide Forums | Help | Site Map

Text field requesting page number to go to

Newbie
 
Join Date: Mar 2007
Posts: 3
#1: Mar 1 '07
I have an index page for an online mag that I'd like to include a text field with "Go to page" text field, and a Go button. I would like the user to be able to type in the page number they want to go to and when submitted it gathers that information and goes to the correct page.

I have been searching for this for days. I must not be searching on the right words because I'm just not finding the answer. Any help would be grately appreciated!!!

Thanks,
GG

drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,577
#2: Mar 1 '07

re: Text field requesting page number to go to


This can't be done with html or css. You need a programming language, in this case, javascript. I will move this to that board so you can get help there.
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#3: Mar 1 '07

re: Text field requesting page number to go to


Quote:

Originally Posted by ggdesigns

I have an index page for an online mag that I'd like to include a text field with "Go to page" text field, and a Go button. I would like the user to be able to type in the page number they want to go to and when submitted it gathers that information and goes to the correct page.

I have been searching for this for days. I must not be searching on the right words because I'm just not finding the answer. Any help would be grately appreciated!!!

Thanks,
GG

A few things, do you want them to type page numbers? I'm not really sure how that would work unless your pages are titled 1.htm 3.htm etc... If your looking for a site search you may need to use server side scripting. Lastly, are you trying to do this with HTML only? I think at least you need javascript.
Newbie
 
Join Date: Mar 2007
Posts: 3
#4: Mar 1 '07

re: Text field requesting page number to go to


thank you drhowarddrfine for moving my post to the javascript discussion board. I thought that was where it needed to be but couldn't find anything pertaining to that when searching javascript for this topic.

The pages are named page1.html, page2.html, etc. I can name them whatever will help make this work. There is a mysql database set up for backend admin so I could use a server side script. What would work?

Thanks very much!
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#5: Mar 1 '07

re: Text field requesting page number to go to


You can do this without server-side code by taking the form value and changing the location. Are you sure everyone will have javascript turned on? If not, you should use a server script or provide links to the other pages.

Anyway, with javascript, use the button onclick event handler to call a function which gets the text input value. Once you have this value, parse it to make sure it's an integer. If it's between 1 and the last page number, just relocate the browser to the new page:
Expand|Select|Wrap|Line Numbers
  1. location.href="page"+num+".html";
where num is your parsed number from the input box.
Newbie
 
Join Date: Mar 2007
Posts: 3
#6: Mar 1 '07

re: Text field requesting page number to go to


thanks everyone for your help!
Reply