this seems to work. if you are planning on adding alot of fleets to the table I would suggest renaming your divs to match their fleet number, then it will become alot simpler, but if there are just a few, this should do...

That is fantastic, exactly what I was looking for! Thank you so much for your time and effort, I appreciate it!

Just a quick niggle; when the user enters text that is not found (I believe it has been labelled "default" - the text "Sorry, nothing found" is displayed. If the user then searches again and the div is found, the default text remains. Is it easy enough to hide this text once a correct search term has been found? -

Before replying I did try and create a "clear" button, which I hoped would 'hide' the default text, while showing the correct div.
I also looked at the "else if" code ...

Cool, that worked but only if I press the "please choose" button twice, (once displays the correct div with the default text and when pressed again the default text is cleared) and notoriously it works flawlessly every time the search is used after the first time

Which is weird; why would it not work as it should? ( I have tested with Chrome and IE)

If you have the time for another quick look the link is below. Don't worry if not, you have done more than enough!!

http://www.nctfleetlist.co.uk/div3.php

Cheers

xelawho

01-05-2012, 10:24 PM

ah, I get it. good thing you're doing the testing on this one :D

so, just take this line out of the if statement:

document.getElementById('fleet1').innerHTML="";

and put it before it (ie, at the start of the function)

and then I think you're good to go.

mulder

01-06-2012, 01:41 PM

That's done it!

Thanks so much for your help, time and effort! I hope you win the 'most helpful member' award, all the best :)

mulder

01-11-2012, 01:49 PM

Hello, me again!

Just wondering, when the above is finished it will contain over 300+ hidden divs thus taking the load time of the page to unrealistic levels.

Is there a way of making it so either;

a) when a user clicks "search" a new page opens and the function displays the correct div
or

b) display a link that, when clicked performs an 'include' function that will display the page that contains the function and divs.

Thanks in advance.

xelawho

01-11-2012, 04:19 PM

I would think carefully about either of those options before going too far down that road.

If I understand what you're proposing, it will mean making 300+ pages of nearly identical content. And possibly the time saved in initial page load will be eaten up as the user has to navigate back and forth between separate pages.

Here's what I would be doing:

Presumably you have all of this information in a database already. Connect the database to the page. On page load (or whenever you decide) the database dumps just the relevant details (Fleet, Registration, Chassis, Body, Seating and Brand) of each available item into the page's "memory" then when the user chooses that fleet number the code constructs one div (the same div, really) and just fills in the relevant blanks.

The page load is much quicker because there will be 1/300th of the html.

It sounds complicated, but it's not, and if you have that database it will probably be the most efficient way to do this (in terms of setup, modifying details later and load times).

That's what I think anyway, without having done speed testing on any of this. Below is a small example with the "database" hardcoded. Let me know what you reckon.