Hi guys
I have a subdomain with 79 individual episode pages, and I'd like to create a Go! button that allows the user to enter which number page of the group they would like to load, and send them to a different page if the number entered is outside the acceptable range of 01 to 79. This would save 79 links in the site map by replacing all with one link.
For example, each page is ep01.html, ep02.html through ep79.html. So ideally I'd have a 2-character text input field pre-populated with "01" followed by a Go! button. If the user enters 27 and pushes "Go!" they load ep27.html. However, if the user enters, say, 81, they load episodes.html because the entry is outside the range of pages I have available to choose from.
Here's the full URL of page one:
http://series.airwolf. tv/episodes/ep01.html
and the fallback page:
http://series.airwolf. tv/episodes/index.html
I tried experimenting with forms and even JavaScript, but I can't seem to marry the input field result with the href. Any ideas?
4 1630 ak1dnar 1,584
Recognized Expert Top Contributor
I didn't see any Form or Input filed on those Pages. how ever i think this will help you to solve your problem.
you can use this form in your pages.
[HTML]<form action="redirec t.php" method="post">
<input name="num" type="text" value="01" maxlength="2" />
<input name="go" type="submit" value="Go!" />
</form>[/HTML]
and the form will call for redirect.php
[PHP]<?php
$num = $_POST['num'];
if($num <= 79)
{
$url = 'ep'.$num.'.htm l';
}
else
{
$url = 'episodes.html' ;
}
header ('Location:'.$u rl);
?>[/PHP]
Here i have assumed that all your pages in this format.
ep[Number].html
And One more thing, In my PHP script i am not checking whether user entering numbers or characters. how ever if it is numbers script will work as per your requirement.
Thank you very much - my PHP knowledge is admittedly redimentary, but I learn with each new idea. I had created a series of offline test pages with different script permutations, but I was mainly playing with JavaScript variables and a form field. I look forward to using this script this evening.
Clark
Works like a charm! If you'd like to see it in action, here's the link: Site map page
Click AIRWOLF: THE SERIES to find it. I can't thank you enough, ajaxrand, for making a script that saves so much space and has a 'gee whiz' benefit.
Clark
P.S. - Would it be too presumptuous to throw out an expansion of this idea? I wonder if this is even possible: when the user types in the number, to the right appears the episode name from a "look-up" list. That way the user is sure it's the one he wants.
Today a user discovered a little glitch with the code. It's the old single-digit-should-be-a-double-digit problem.
When a user types in a single digit they get no page at all because the pages are all 01, 02, etc.
I experimented with an additional if/else command but haven't found the right syntax. What can I use?
Current script:
[PHP]
$num = $_POST['num'];
if($num <= 79)
{
$url = 'ep'.$num.'.htm l';
}
else
{
$url = 'episodes.html' ;
}
header ('Location:'.$u rl);
[/PHP]
Things I already tried adding:
[PHP]if($num <= 10)
{
$url = 'ep0'.$num.'.ht ml';
}
else[/PHP]
[PHP]if($num <= [1-9])
{
$url = 'ep'.$num.'.htm l';
}
else[/PHP]
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Paul |
last post by:
I want to use sessions to cover myself in case the user switches off cookies
so I am passing the session ID manually through a hidden input field. This
is what I have so far.
index.php page contains:
<?php
$_SESSION = "";
$_SESSION = "";
|
by: Paul |
last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and
session.use_trans_sid = 1 in my php.ini file. Index.php contains:
----------------------------------------------------------------------------
<?php
ini_set("session.use_cookies", "off");
ini_set("session.use_trans_sid", "on");
session_start();
$_SESSION = "";
$_SESSION = "";
echo "<form method='POST' action='login.php'>
|
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {
document.images.src = eval("mt" +menu+ ".src")
}
alert("imgOff_hidemenu");
hideMenu=setTimeout('Hide(menu,num)',500);
|
by: veganeater |
last post by:
Hi Everyone,
I was wondering if there was a way to pass a variable to a popup window. The
purpose is make it so when a user clicks on a specific region/link of the
glossary page, a popup opens with the related description. This is done and
is obviously not a concern. However, now I would like to make it so the
corresponding row becomes highlighted (changes background colour via DOM).
I imagine it can be done, but I'm at a loss for...
|
by: JJ |
last post by:
Hi,
I need to pass a dataset to another win form along with a SqldataAdapter.
I don't want to recreate the SqlDataAdapter again either. So to pass to
another Win form in my windows form app, do I create the procedure to pass by
ref? Which means I don't need to add ByRef because it is defaulted by ref,
correct? And in the constructor of the win form that gets created. I need to
add in parameters a DataSet and SqlDataAdapter correct? What...
| |
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and click a button to
determine whether the zip code is unique. If the zip code is not unique,
another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip
code is passed to the lookup form/dialog by reference. I then load a...
|
by: Deano |
last post by:
Apparently you can only do this with one value i.e Call
MyAssetLocationZoom(Me!txtLocation, "Amend data")
This runs;
Public Sub MyAssetLocationZoom(ctl As Control, formName As String)
On Error GoTo err_zoom
strFormName = formName
|
by: itarizin |
last post by:
Today I found as ignorance owe me..
Let me explain what I'm tring to do and fail (fail: in my needs)
For example, I've my stupid class:
public class Hello
{
private int x = 0;
public Hello()
|
by: rfr |
last post by:
I have a need to use a single version of a Visitor Response Feedback Form on
numerous
HTML documents. Rather than have numerous versions of this, one on each HTML
document, it makes more sense to have ONE FORM and use it from each HTML
document that needs it.
But, the visitor should see a title on the form that relates to the specific
page about which they are giving the feedback. And the results of the form
must include what page was...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |