The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

2 Pages V  1 2 >  
Reply to this topicStart new topic
> Navigation via Text Box, How can I add direct navigation via a form text box?
Kris Didymus
post Apr 26 2008, 05:39 AM
Post #1


Newbie
*

Group: Members
Posts: 11
Joined: 26-April 08
Member No.: 5,519



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Apr 26 2008, 10:06 AM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



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?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Kris Didymus
post Apr 27 2008, 07:44 AM
Post #3


Newbie
*

Group: Members
Posts: 11
Joined: 26-April 08
Member No.: 5,519



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...

Attached File  menu.txt ( 156bytes ) Number of downloads: 761
Attached File  tree.html ( 36.04k ) Number of downloads: 1160


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?

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Apr 27 2008, 09:34 AM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,732
Joined: 9-August 06
Member No.: 6



It's JavaScript, not Java. JavaScript is a highly optional feature.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Apr 27 2008, 10:46 AM
Post #5


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



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.)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Kris Didymus
post Apr 27 2008, 11:28 PM
Post #6


Newbie
*

Group: Members
Posts: 11
Joined: 26-April 08
Member No.: 5,519



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Apr 28 2008, 12:19 AM
Post #7


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Apr 28 2008, 10:37 AM
Post #8


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,732
Joined: 9-August 06
Member No.: 6



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Kris Didymus
post Apr 29 2008, 03:18 AM
Post #9


Newbie
*

Group: Members
Posts: 11
Joined: 26-April 08
Member No.: 5,519



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Apr 29 2008, 12:16 PM
Post #10


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Apr 29 2008, 02:17 PM
Post #11


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Kris Didymus
post Apr 29 2008, 11:23 PM
Post #12


Newbie
*

Group: Members
Posts: 11
Joined: 26-April 08
Member No.: 5,519



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Apr 30 2008, 12:43 AM
Post #13


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Kris Didymus
post Apr 30 2008, 02:45 AM
Post #14


Newbie
*

Group: Members
Posts: 11
Joined: 26-April 08
Member No.: 5,519



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Apr 30 2008, 03:06 AM
Post #15


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Apr 30 2008, 03:15 AM
Post #16


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



Incidentally, what on earth are the frames for?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Apr 30 2008, 04:55 AM
Post #17


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Apr 30 2008, 06:29 AM
Post #18


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Kris Didymus
post Apr 30 2008, 07:16 AM
Post #19


Newbie
*

Group: Members
Posts: 11
Joined: 26-April 08
Member No.: 5,519



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Apr 30 2008, 09:02 AM
Post #20


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



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.




User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

2 Pages V  1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 09:33 PM