PDA

View Full Version : Script won't work when uploaded



gold2040
12-24-2005, 05:06 PM
Hi

I got a script here that i'm using for a search engine


<script>
function check(){
val = document.form1.textarea.value;

switch(val){
case "day of the tentacle":
case "Day of the Tentacle":
case "dott":
case "DOTT":
case "tentacle":
case "Tentacle":
case "Maniac Mansion":
case "maniac mansion":
location = 'http://abandonware.hostingzero.com/details/dott/';
break;

case "the settlers":
case "The Settlers":
case "Settlers":
case "settlers":
location = 'http://abandonware.hostingzero.com/details/settlers1/';
break;

case "Beneath a Steel Sky":
case "beneath a steel sky":
location = 'http://abandonware.hostingzero.com/details/beneathasteelsky/';
break;

case "Genesia":
case "genesia":
location = 'http://abandonware.hostingzero.com/details/genesia/';
break;

case "Mortal Kombat 1":
case "mortal kombat 1":
location = 'http://abandonware.hostingzero.com/details/mortalkombat1/';
break;

case "Railroad Tycoon Deluxe":
case "railroad tycoon deluxe":
location = 'http://abandonware.hostingzero.com/details/railroadtycoondeluxe/';
break;

case "Sim Earth":
case "sim earth":
location = 'http://abandonware.hostingzero.com/details/simearth/';
break;

case "Lords of the Realm 1":
case "lords of the realm 1":
location = 'http://abandonware.hostingzero.com/details/lordsoftherealm1/';
break;

case "Sam and Max Hit the Road":
case "sam and max hit the road":
location = 'http://abandonware.hostingzero.com/details/samandmaxhittheroad/';
break;

case "Loom":
case "loom":
location = 'http://abandonware.hostingzero.com/details/loom/';
break;

case "Magic Boy":
case "magic boy":
location = 'http://abandonware.hostingzero.com/details/magicboy/';
break;

case "Dragonsphere":
case "dragonsphere":
location = 'http://abandonware.hostingzero.com/details/dragonsphere/';
break;

case "Ishar 2":
case "ishar 2":
location = 'http://abandonware.hostingzero.com/details/ishar2/';
break;

case "Hemidall 2":
case "hemidall 2":
location = 'http://abandonware.hostingzero.com/details/hemidall2/';
break;

case "Lords of the Realm 2":
case "lords of the realm 2":
location = 'http://abandonware.hostingzero.com/details/lordsoftherealm2/';
break;

case "The Lion King":
case "the lion king":
case "Lion King":
case "lion king":
location = 'http://abandonware.hostingzero.com/details/thelionking/';
break;

case "The Jungle Book":
case "the jungle book":
case "Jungle Book":
case "jungle book":
location = 'http://abandonware.hostingzero.com/details/thejunglebook/';
break;

case "Aladdin":
case "aladdin":
location = 'http://abandonware.hostingzero.com/details/aladdin/';
break;

case "Master of Magic":
case "master of magic":
location = 'http://abandonware.hostingzero.com/details/masterofmagic/';
break;

default:
location = 'http://abandonware.hostingzero.com/noresults.shtml';
break;
}
}
</script>
<form name="form1" method="post" action="">
<input name="textarea" type="text" size=11 value="">
<input type=button value="Go" onClick="check();" STYLE="background-color: #000000; color: #ffffff; font-weight: bold; font-size: 5pt;">
</form>

It works fine locally but when I upload it doesn't seem to work

The error says

'document.form1.textarea' is null or not an object

Here the link to the page

http://abandonware.hostingzero.com/screenshots/dott

Cheers for any help

gold2040

mwinter
12-24-2005, 11:35 PM
First, I would say that that script is not a particularly good idea. It doesn't really search, does it? I would expect to be able to type in "day tentacle" because that should be enough to limit the results, but that would get me nothing. At the very least, you should normalise the case first using the String.prototype.toLowerCase method.

As for the failure, I can only attribute that to just how badly written the rest of the markup is in the document. Looking at the DOM inspector, the form element in question doesn't exist, presumably because it was removed for some reason during error correction. Rewrite the page (without absolutely-positioning everything in sight, this time), and validate (http://validator.w3.org/) it.

Not the best of news just before Christmas, I'll grant you, but your best bet to fixing the problem and avoiding any similar problems in the future.

Mike

gold2040
12-25-2005, 09:43 PM
Hi

Cheers Mike. I'll see what I can do. Serif WebPlus absolutely positions every page it does I think which is a tad annoying. Do u have any knowledge on the cleaness of Dreamweavers code which i'm thinking of switching to or which editor has the cleanest code

gold2040 :)

p.s Do u know how hard it is to hand code a basic search engine or any other good search engine scripts

sorry for all the questions.just curious

mwinter
12-26-2005, 03:28 PM
Do u have any knowledge on the cleaness of Dreamweavers code [...]I've never used it personally, but I do know that the code quality depends entirely upon how it's used. Using it solely in WYSIWYG mode, letting it do the majority of the work, will produce rubbish. If you have sound knowledge of HTML and CSS, then its output will be fine (not least because you can control anything stupid it tries to do).


[...] or which editor has the cleanest codeI assume you're still referring to WYSIWYG editors. All of them produce abysmal code unless carefully controlled. Some will still, regardless. It's in the nature of that sort of software.

Only a human can do a decent job.


p.s Do u know how hard it is to hand code a basic search engine or any other good search engine scriptsIf I were you, I'd just make sure that your site can be indexed properly, then used an existing remote engine like Google Site Search (http://www.google.co.uk/searchcode.html#both).

Mike

cr3ative
12-26-2005, 03:44 PM
I assume you're still referring to WYSIWYG editors. All of them produce abysmal code unless carefully controlled. Some will still, regardless. It's in the nature of that sort of software.

Only a human can do a decent job.

I'm certainly not disagreeing here, but an interesting tidbit of information - I'm an offical beta tester for MS Office 12, and their new version of Frontpage (now called SharePoint Designer 12) outputs the most coherent code I've ever seen out of a WYSIWYG editor. It's fully XHTML 1.1 and CSS 2.0 compliant.

It'll be an interesting product to look out for when it's released.

gold2040
12-26-2005, 04:27 PM
Hi

Thanks for everyone's help

I'll take all the advice on board

gold2040 :)

jscheuer1
12-26-2005, 05:13 PM
. . . new (sic beta) version of Frontpage (now called SharePoint Designer 12) outputs the most coherent code I've ever seen out of a WYSIWYG editor. It's fully XHTML 1.1 and CSS 2.0 compliant.

You mean MS finally did something right? It could only be because you were onboard. :cool:

cr3ative
12-26-2005, 07:38 PM
You mean MS finally did something right? It could only be because you were onboard. :cool:

*blush*
I've had to send them about 20 bug reports though. I just click the frowny face and send abuse to them, it's fantastic. :)

http://img254.imageshack.us/img254/9176/thisfilenameshouldbeshortertha.jpg

Word 12 will certainly be a shock to the system though, be warned. It's incredible, but the first time you use it, the interface is so quirky that it makes you want to vomit from overuse of fading. And it can save to PDFs. Finally.

Wait, what am I doing? Endorsing Microsoft?! Aargh!