473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Passing a form variable into a URL

21
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?
Apr 19 '07 #1
4 1613
ak1dnar
1,584 Expert 1GB
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="redirect.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.'.html';
}
else
{
$url = 'episodes.html';
}
header ('Location:'.$url);
?>[/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.
Apr 19 '07 #2
Wolfman
21
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
Apr 19 '07 #3
Wolfman
21
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.
Apr 20 '07 #4
Wolfman
21
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.'.html';
}
else
{
$url = 'episodes.html';
}
header ('Location:'.$url);
[/PHP]

Things I already tried adding:

[PHP]if($num <= 10)
{
$url = 'ep0'.$num.'.html';
}
else[/PHP]

[PHP]if($num <= [1-9])
{
$url = 'ep'.$num.'.html';
}
else[/PHP]
Dec 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
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...
1
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:...
3
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) {...
6
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...
3
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...
8
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...
13
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...
9
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...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.