Help - Search - Members - Calendar
Full Version: Navigation via Text Box
HTMLHelp Forums > Web Authoring > Web Site Functionality
Kris Didymus
I have built a family tree website (http://www.didymus.org.uk) and so far visitors can only access one of my ancestor's details by selecting them from two drop-down menus (one for surname and one for forename).

The structure of the site gives each of my ancestors a unique reference number (URN) based on the alphabetical position of their initials. Each ancestor has their own page which is named (URN).htm, for example my great grandfather's URN is 538 and the URL for his page is 538.htm

What I WANT to do is add a text box in a form. When a visitor types a URN in to the text box and presses a "Go" button, the form simply sends them to the relevant page.

For example, if I were to type 538 in to the box and click GO the form directs my browser to 538.htm

Can anybody help with how to achieve this and ALSO (if it's not too much trouble) come up with a way to have the form return an error page if a URN is incorrectly entered or doesn't exist?

Your help would be GREATLY appreciated.

Kindest regards.

KD.
Darin McGrew
FWIW, nothing happens when I select a name. How am I supposed to submit the form.

Anyway, do you have access to the server-side code that runs the site? Can you modify it? What language is it written in?
Kris Didymus
It works fine on every system I've tried it on. Select a name and without doing anything else, it loads the page in the right hand side.

I have attached two files to this reply. The existing menus use Java. Not sure why it doesn't work on your PC but any suggestions would be greatly appreciated. One file is the tree.htm which creates the menus and the other is the related Javascript in a txt format...

Click to view attachmentClick to view attachment

What I want to do is add an ADDITIONAL means of selecting an individual.

Kindest regards.

KD.



QUOTE(Darin McGrew @ Apr 26 2008, 04:06 PM) *

FWIW, nothing happens when I select a name. How am I supposed to submit the form.

Anyway, do you have access to the server-side code that runs the site? Can you modify it? What language is it written in?

pandy
It's JavaScript, not Java. JavaScript is a highly optional feature.
Darin McGrew
As pandy pointed out, I don't leave JavaScript (which is not the same as Java) enabled for random untrusted sites. I am not alone. (Some browsers don't even need a plugin to selectively enable/disable JavaScript.)
Kris Didymus
How naive am I?!

Okay. So now I know that there is a difference AND that this could mean alot of people can't view my site as I intended.

So what are my options? Is there a way of detecting that people don't have Javascript enabled in their internet options and asking them to enable? Or do I need to re-write large portions of my site to eradicate the Javascript element?

This I'm afraid would be tricky as I'm no programmer. I use Javascript from public repositories because I have no knowledge of PHP, Perl, ASP etc.

For example, with Javascript enabled you should see a nice date and time in the top right. I use a meta-refresh to re-load the top frame every minute to keep it accurate.

About the only "clever" bit of my site which does NOT use Javascript is the Contact Us page which uses Formmail!!!!

I'd be grateful for any help or advice anybody could give an amateur (and not particularly knowledgeable) web designer.
Brian Chandler
QUOTE
This I'm afraid would be tricky as I'm no programmer. I use Javascript from public repositories because I have no knowledge of PHP, Perl, ASP etc.


The logic of this escapes me. Is it different from:

"I use PHP from public repositories because I have no knowledge of Javascript, Perl, ASP etc."

I don't think there's any reason to get worked up about using javascript - frankly the logical argument for disabling javascript is very similar to the logical argument for not using the Web - "You're safer". But Javascript isn't particularly appropriate for doing what ought to be a database lookup - every time you add a relative, presumably you have to edit the source of this page by hand, no? Much better to find a genealogy application in php/mysql or whatever.

And what on earth is the point of putting the date and time on the page? My computer already shows me, in a place I know where to look for it.
pandy
QUOTE
I don't think there's any reason to get worked up about using javascript


A agree with you, when it's done right. I wouldn't use JS as the only way to naviagate to what looks like important content.
Kris Didymus
Your replies are deeply appreciated. I'm fairly new to this and wanted to find a way of using drop-down boxes to select an ancestor's record. Javascript seemed to be an easy and freely available solution.

I think I might add an "A-Z" page on the left hand side written in plain old HTML. That way if people have Javascript disabled they will still be able to find the information.

As for the date and time thing, I was told a long time ago that having a date and time on my site would reassure visitors that the content was still fresh. But I guess I could get rid of that if needs be.

To return to my initial question then, does anybody know how to build a simple HTML form that would send a visitor to a page by taking their input (i.e 538) and hyperlinking to their input plus .htm?

This in conjunction with the HMTL A-Z index should solve at least some of my problems!

Many thanks again for your interest and assistance.

KD.
Darin McGrew
Please see the FAQ entry How can I use forms for pull-down navigation menus? What you're trying to do is basically the same thing, except you'd use a text input element, rather than a select element.
Brian Chandler
QUOTE
As for the date and time thing, I was told a long time ago that having a date and time on my site would reassure visitors that the content was still fresh. But I guess I could get rid of that if needs be.



Try a bit of logic here. If there's a javascript thingy to echo the current time on my computer, I know that you have added the javascript thingy - but of course I have no idea when. You might have last touched the page 10 years ago.

If there is a date at the bottom of the page: "Last updated [real plausible date in the near past]" then I might be persuaded.
Kris Didymus
Hey - I'm with you on that one Brian.

I KNOW it's pointless and that it's reiterating what a visitor already knows.

It's on my list for review when I next update the site.

Darin - thank you. The only stumbling block for me is going to be that with pull-down menus you define the hyperlink within the <form> element. I don't want to define the hyperlink - I just want to add the characters .htm to an inputted number and have the user whisked to that URL.

I shall, however, endeavour to figure this out.
Darin McGrew
All the server-side program that processes the form data knows is that it received a name=value pair. It doesn't care whether the name came from a select element and the value from an option element, or whether the name and value both came from a text input element.
Kris Didymus
Darin.

I can't thank you enough. I've managed to locate a CGI script called Jumpbox which is now installed on my server.

A simple form as follows calls the script and produces the hyperlink:

<p><form method=get action="http://www.didymus.org.uk/public_html_cgi-bin/jumpbox.cgi" onsubmit="iframe1.location.href='tree/'+jb.value+'.htm'; return false;">
<input type="text" name="jb" size="8">
<input type="submit" value="Go">
</form></p>

You're a star. If it weren't for you providing a link to that website I'd still be tearing my hair out!

I'm going to work on using this to control the existing drop-down menus as well as this will negate the need for people to be running Javascript. I'll start work on that tomorrow.

Meanwhile, as you will see if you visit my website I'm planning to produce an index page as well in plain old HTML to ensure maximum compatability.

People have suggested using a PHP based Genealogy utility to create my website but I wanted control over the look, feel and functionality and I've yet to find a decent package that affords me that.

So as laborious as producing hundreds of pages of HTML will be, with your help, I should have a reasonably good looking site which works across most browsers by this time next year!

Thank you to everyone who submitted replies to my question.
Brian Chandler
You say "A simple form as follows calls the script and produces the hyperlink:"

QUOTE

<p><form method=get action="http://www.didymus.org.uk/public_html_cgi-bin/jumpbox.cgi" onsubmit="iframe1.location.href='tree/'+jb.value+'.htm'; return false;"><input type="text" name="jb" size="8"><input type="submit" value="Go"></form></p>


But it doesn't. Try accessing the script:

"The requested URL /public_html_cgi-bin/jumpbox.cgi was not found on this server."

The javascript handler presumably _does_ work (as long as javascript is enabled), but this is where we came in.

"public_html" is a common name for the directory at the root of the web document tree, so I expect the address should be

/cgi-bin/jumpbox.cgi

But calling this, with jb=3456 gives:

Not Found
The requested URL /cgi-bin/3456 was not found on this server.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/1.3.41 Server at www.didymus.org.uk Port 80

Basically the script you need is exceedingly trivial - about 4 lines in PHP:

(Something *roughly* like)

$code = $_GET['jb'];
if(file_exists("$code.htm"))
{ header("redirect to $code.htm")); // LUTD
quit();
}

// generate error page "Not found" ** LUTD

(LUTD = look up the details)

Longer term, I strongly recommend against trying to generate "hundreds" of html pages the manual way. By no. 57, the time spent doing maintenance will slow you to a crawl.
Brian Chandler
Incidentally, what on earth are the frames for?
Darin McGrew
QUOTE
if(file_exists("$code.htm"))
The script should also make sure that $code is just a number, with no other characters. If $code begins with "../" then the script can provide access to files you didn't intend to provide access to.
Brian Chandler
QUOTE(Darin McGrew @ Apr 30 2008, 06:55 PM) *

QUOTE
if(file_exists("$code.htm"))
The script should also make sure that $code is just a number, with no other characters. If $code begins with "../" then the script can provide access to files you didn't intend to provide access to.


Not exactly - we are not including or echoing the file, only giving a redirect to somewhere, so if that is not published the redirect won't work. But of course the general point is that this is a bad idea.

Another bad idea is giving everyone a number based on their initials - so people with quite different initials may get the same number (if 1234 is 'abcd', 'lcd', 'awd', frigs ample). At least use the initials plus distinguishing numbers or something else human-friendly.

But anyway the way to do this is with a database - no discussion possible, really.
Kris Didymus
Brian.

That was a typo on my part. There should be a / and not a _ between public_html and cgi-bin. It's now rectified. I've tried the site on a few computers now including a very secure work machine and it appears to function as it should.

I agree with your sentiment that I need to concentrate of finding a dB solution instead of producing pages of HTML manually. But as a total amateur this is something I have no idea where to start with. I've find some websites offering authoring software but the results aren't user-friendly enough for me.

I've added a custom 404 page to the /tree directory now giving guidance for mis-typed or mistaken URN references.

Taking all of the replies to this thread in to account, I need to bite the bullet and start again from scratch. Thing is, I've reached that point where so much work has gone in to it I'm not sure I have the energy!

You're right, of course. Absolutely. However, the best I can do for now until my skills improve is to make what I have work and build upon it.

KD.
Brian Chandler
QUOTE
That was a typo on my part. There should be a / and not a _ between public_html and cgi-bin. It's now rectified. I've tried the site on a few computers now including a very secure work machine and it appears to function as it should.


Uh, no:

"The requested URL /public_html/cgi-bin/jumpbox.cgi was not found on this server."
"Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

As I said before, the address of your form is

http://www.didymus.org.uk/cgi-bin/jumpbox.cgi

But this script does not work - either at all, or certainly not in the way you hope.

The reason you think it does is that you have also added a javascript kludge to do the same thing, and provided javascript is enabled the "jump" appears to work. But the script is not even being accessed.

If the script were accessed it wouldn't work, because it's some general "jump" script, where you need to put in the complete address as the argument - and it seems to be "wrong" anyway. As I said above, if you access what would be the result of entering 3456 into the form and submitting it - that's here:

http://www.didymus.org.uk/cgi-bin/jumpbox.cgi?jb=3456

You get not ".../jumpbox.cgi not found", but

"The requested URL /cgi-bin/3456 was not found on this server."

I.e. it has tried to "jump", but to the file called "3456" in the cgi-bin directory. You want to jump to /tree/3456.htm

I think... but you have more horrible javascript kludging everything up so nothing is bookmarkable; at least here it seems to lose the top frame that is just a "banner". Frankly I would start again.

Curiously, it says "optimized for a minimum resolution of something", but actually the entire content sits in a much smaller box, including nonstandard scrolling iframe to make sure we can't see it all in one go, even with the supposed "design resolution"... hmmm.




Kris Didymus
You are, of course, absolutely right. When I try to access http://www.didymus.org.uk/cgi-bin/jumpbox.cgi?jb=3456 I get the error you said I would.

Luckily being a police officer I have no hair to speak of because otherwise I'd have torn it out in handfuls!

Bottom line - I should leave this kind of thing to people who know what they're doing. I've tried to run before I can walk and the result is a website which works fine on my machine but not on others.

The only saving grace now is that I've added a pure HTML navigation option in the form of an A-Z index so if people are patient enough to try all three navigation options they'll eventually come across one that works. Hmm.

I need to buy me some books on writing websites properly because leeching Javascript frankly isn't the way forward.

For now, until I've decided what I'm going to do with this site, I've emboldened and highlighted the line across the bottom that reads "You MUST have Javascript enabled in your browser to use this site".

As for the design resolution thing, that was deliberate. I wanted a "mini-site" as opposed to a full page. Don't ask me why, I just like the look of it.

Yes, it means using frames and iframes but that was what I wanted having tried several times to design a full screen site and never having been entirely happy with the result.

Thanks once again for all of your help and advice. Rest assured I've taken it on board. Hey that rhymes!

KD.
Kris Didymus
Brian.

I've had a brain wave but I might need your help to get my head around this.

Okay, here goes..

tree.htm contains the following form:

<form method=get action="http://www.didymus.org.uk/cgi-bin/jumpbox.cgi" onsubmit="iframe1.location.href='tree/'+jb.value+'.htm'; return false;">
<input type="text" name="jb" size="8">
<input type="submit" value="Go">
</form>

The form takes the user's input (i.e. 1234), adds a prefix of "tree/" and a suffix of ".htm" and sends it to the CGI script.

So if I use the URL http://www.didymus.org.uk/cgi-bin/jumpbox.cgi/1234 I'm not in fact submitting data as the cgi would receive it from the site. When the form is submitted it's sent as the full URL of the page they're trying to access (as long as they don't make a mistake in the URN)

I'm not sure if the jumpbox script contains any Javascript but looking at it, I don't think so.

So if the QIKJUMP section of my site doesn't function without Javascript I can't explain why. After all, the form only calls jumpbox.cgi and doesn't send the result to anything else.

Aargh. I feel like my head is going to explode!!
Kris Didymus
Sorry. One more thought. Because the form instructs the cgi to send the page to "iframe1", it doesn't work unless you're in a page with an "iframe1" defined. I guess this is why it doesn't work when you're testing it outside of my website.
Brian Chandler
QUOTE
tree.htm contains the following form:

CODE

<form method=get action="http://www.didymus.org.uk/cgi-bin/jumpbox.cgi" onsubmit="iframe1.location.href='tree/'+jb.value+'.htm'; return false;">
<input type="text" name="jb" size="8">
<input type="submit" value="Go"></form>


The form takes the user's input (i.e. 1234), adds a prefix of "tree/" and a suffix of ".htm" and sends it to the CGI script.


No it doesn't. The "action" parameter tells the browser where to submit; the <input> elements tell it what arguments to provide. But you have added a javascript handler for the "submit" event thus:

onsubmit="iframe1.location.href='tree/'+jb.value+'.htm'; return false;"

This says that when the form is submitted, the location in iframe1 should be changed to 'treeNNN.htm' where NNN is the value in the jb input element (this is why the "jump" "works", in javascript), then the onsubmit handler returns false, which tells the browser not to submit after all. So the form never gets submitted.
Darin McGrew
QUOTE
For now, until I've decided what I'm going to do with this site, I've emboldened and highlighted the line across the bottom that reads "You MUST have Javascript enabled in your browser to use this site".
See also This page optimized for ...
Brian Chandler
QUOTE(Darin McGrew @ May 1 2008, 04:31 PM) *

QUOTE
For now, until I've decided what I'm going to do with this site, I've emboldened and highlighted the line across the bottom that reads "You MUST have Javascript enabled in your browser to use this site".
See also This page optimized for ...


Why? It doesn't have anything to do with his message about javascript, which is basically correct. And who is the "I" in this "optimized" rant? When this "I" says:

There is also information that can not be prepared for text-only browsers. (A city plan, for example.) But I bet your information is not of that type.

... this comes over as extremely arrogant. Perhaps not exactly arguing with the customer, but close...
Kris Didymus
Brian.

Thank you. Now I understand. I'm afraid when God was giving out brains I was at the back of the queue looking the other way!

I see now that the form itself contains the JS element and that by virtue of the "return false" argument it stops operating as soon as the JS has done its job, BEFORE it sends anything to the CGI.

In which case I will get rid of the CGI script from my server and amend tree.htm accordingly. There's no point keeping a non-functional CGI script on there really is there?

Thanks again.

KD.
Frederiek
QUOTE(Brian Chandler @ May 1 2008, 10:07 AM) *
And who is the "I" in this "optimized" rant?

FYI, it's at the end of the article (under the conclusion).
Brian Chandler
QUOTE(Frederiek @ May 1 2008, 10:11 PM) *

QUOTE(Brian Chandler @ May 1 2008, 10:07 AM) *
And who is the "I" in this "optimized" rant?

FYI, it's at the end of the article (under the conclusion).


Yes, I noticed that later. Anyway, it's all dreadfully dated - stuff about not everyone having Windows 95 or the time to download images is not very persuasive.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.