Computing.Net > Forums > Web Development > JavaScript help please!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

JavaScript help please!

Reply to Message Icon

Name: Leo the 28C (by Sulfurik)
Date: August 12, 2005 at 17:06:40 Pacific
OS: Windows XP Home
CPU/Ram: 1.4 GHz/480 MB
Comment:

Hello everyone! :D

<code>------

<html>

<head>

<title>SulfurMidis - Search</title>

<style type="text/css">
h1 { font: italic bold 25pt "Arial" }
h1 { text-decoration: underline }
h2 { font: italic bold 20pt "Times New Roman" }
h2 { text-decoration: underline }
p.double { border-style: double }
p.margin {margin-left: 2cm}
</style>

<script language="JavaScript" type="text/javascript">
<form name="SearchForm" action="javascript:FindMidi(document.SearchForm.Phrase.value)">
<input type="text" name="Phrase" size=25>
<input type="submit" value="Search MIDI">
</form>

<hr>

</center>
</body>
</html>

------</code>

Look for the "// ERROR HERE //" comment in the code... Anybody know what causes it? Much thanks! ;)

http://www.boredsource.com/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Ruffle Mayo says ROFLMAO! :D



Sponsored Link
Ads by Google

Response Number 1
Name: Leo the 28C (by Sulfurik)
Date: August 12, 2005 at 17:07:59 Pacific
Reply:

Wait, it came up wrong... Sorry!
Here:

<code>-----

<html>

<head>

<title>SulfurMidis - Search</title>

<style type="text/css">
h1 { font: italic bold 25pt "Arial" }
h1 { text-decoration: underline }
h2 { font: italic bold 20pt "Times New Roman" }
h2 { text-decoration: underline }
p.double { border-style: double }
p.margin {margin-left: 2cm}
</style>

<script language="JavaScript" type="text/javascript">
function FindMidi(searchWord)
{
// This tells if it has found any matches or not
var hasFound = false;

// The MIDI database (only contains these 2 for now...)
var Database = new Array();
Database[0] = 'hello.mid';
Database[1] = 'foobar.mid';

// The search words that the user specified
var searchWords = searchWord.split(' ');

// The result page
var Result = '';

// Write some basic stuff to it
Result += '<HTML>\n';
Result += '<HEAD>\n';
Result += '<TITLE>SulfurMidis - Search Results</TITLE>\n';
Result += '</HEAD>\n';
Result += '<BODY>\n';

// For each MIDI in the database,
for (var x = 0; x < Database.lenght; x++)
{

// ERROR HERE // This statement, and I'm assuming the rest of them inside this loop, don't execute
window.alert("Database.lenght: " + Database.length + " | X: " + x)

// For each search term,
for (var y = 0; y < searchWords.lenght; y++)
{
// If the current item is in the database,
if (Database[x].indexOf(searchWords[y]) >= 1 )
{
// Guess the starting letter
var let = '';

// If it starts with a letter,
if (Database[x].substring(1, 1).toLower() == 'a' || Database[x].substring(1, 1).toLower() == 'b' ||
Database[x].substring(1, 1).toLower() == 'c' || Database[x].substring(1, 1).toLower() == 'd' ||
Database[x].substring(1, 1).toLower() == 'e' || Database[x].substring(1, 1).toLower() == 'f' ||
Database[x].substring(1, 1).toLower() == 'g' || Database[x].substring(1, 1).toLower() == 'h' ||
Database[x].substring(1, 1).toLower() == 'i' || Database[x].substring(1, 1).toLower() == 'j' ||
Database[x].substring(1, 1).toLower() == 'k' || Database[x].substring(1, 1).toLower() == 'l' ||
Database[x].substring(1, 1).toLower() == 'm' || Database[x].substring(1, 1).toLower() == 'n' ||
Database[x].substring(1, 1).toLower() == 'o' || Database[x].substring(1, 1).toLower() == 'p' ||
Database[x].substring(1, 1).toLower() == 'q' || Database[x].substring(1, 1).toLower() == 'r' ||
Database[x].substring(1, 1).toLower() == 's' || Database[x].substring(1, 1).toLower() == 't' ||
Database[x].substring(1, 1).toLower() == 'u' || Database[x].substring(1, 1).toLower() == 'w' ||
Database[x].substring(1, 1).toLower() == 'x' || Database[x].substring(1, 1).toLower() == 'y' ||
Database[x].substring(1, 1).toLower() == 'z')
{
// Then just use the letter
let = Database[x].substring(1, 1).toLower() + '/';
}

// Else if it's a humber,
else if (Database[x].substring(1, 1) == '1' || Database[x].substring(1, 1) == '2' || Database[x].substring(1, 1) == '3' || Database[x].substring(1, 1) == '4' || Database[x].substring(1, 1) == '5' || Database[x].substring(1, 1) == '6' || Database[x].substring(1, 1) == '7' || Database[x].substring(1, 1) == '8' || Database[x].substring(1, 1) == '9' || Database[x].substring(1, 1) == '0')
{
// Use "num"
let = 'num/';
}

// Else,
else
{
// Use "sym" (symbol)
let = 'sym/';
}

// Add the let variable as the folder name and Database[x] as the filename
Result += '' + Database[x] + '

\n';

// It has found a match
hasFound = true;
}
}
}

// If it hasn't found any matches,
if (hasFound == false)
{
// Shout out the worst message you could get on a file search :-)
Result += '0 matches were found.';
}

// Write to the document
this.document.open();
this.document.write(Result);
this.document.close();
}
</script>

</head>

<body>

<center>


<form name="SearchForm" action="javascript:FindMidi(document.SearchForm.Phrase.value)">
<input type="text" name="Phrase" size=25>
<input type="submit" value="Search MIDI">
</form>

<hr>

</center>
</body>
</html>

-----</code>

http://www.boredsource.com/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Ruffle Mayo says ROFLMAO! :D


0

Response Number 2
Name: Leo the 28C (by Sulfurik)
Date: August 13, 2005 at 11:29:12 Pacific
Reply:

Got it! :D Sorry, that was the very first JavaScript I ever made and I messed up... but this works as I expected:

<code>-----
function FindMidi(searchWord)
{
// This tells if it has found any matches or not
var hasFound = false;

// The MIDI database (only contains these 2 for now...)
var Database = new Array();
Database[0] = 'hello.mid';
Database[1] = 'foobar.mid';

// The search words that the user specified
var searchWords = searchWord.split(' ');

// The result page
var Result = '';

// Write some basic stuff to it
Result += '<HTML>\n';
Result += '<HEAD>\n';
Result += '<TITLE>SulfurMidis - Search Results</TITLE>\n';
Result += '</HEAD>\n';
Result += '<BODY>\n';

// For each MIDI in the database,
for (var x = 0; x < 2; x++)
{

// ERROR HERE // This statement, and I'm assuming the rest of them inside this loop, don't execute
window.alert("Database.lenght: " + Database.length + " | X: " + x)

// For each search term,
for (var y = 0; y < 1; y++)
{
window.alert('Database[' + x + ']: ' + Database[x] + ' | ' + 'searchWords[' + y + ']: ' + searchWords[y]);
// If the current item is in the database,
if (Database[x].indexOf(searchWords[y]) > -1 )
{
// Guess the starting letter
var let = '';

window.alert(Database[x].charAt(0).toLowerCase());
// If it starts with a letter,
if (Database[x].substring(1, 1).toLowerCase() == 'a' || Database[x].substring(1, 1).toLowerCase() == 'b' ||
Database[x].charAt(0).toLowerCase() == 'c' || Database[x].charAt(0).toLowerCase() == 'd' ||
Database[x].charAt(0).toLowerCase() == 'e' || Database[x].charAt(0).toLowerCase() == 'f' ||
Database[x].charAt(0).toLowerCase() == 'g' || Database[x].charAt(0).toLowerCase() == 'h' ||
Database[x].charAt(0).toLowerCase() == 'i' || Database[x].charAt(0).toLowerCase() == 'j' ||
Database[x].charAt(0).toLowerCase() == 'k' || Database[x].charAt(0).toLowerCase() == 'l' ||
Database[x].charAt(0).toLowerCase() == 'm' || Database[x].charAt(0).toLowerCase() == 'n' ||
Database[x].charAt(0).toLowerCase() == 'o' || Database[x].charAt(0).toLowerCase() == 'p' ||
Database[x].charAt(0).toLowerCase() == 'q' || Database[x].charAt(0).toLowerCase() == 'r' ||
Database[x].charAt(0).toLowerCase() == 's' || Database[x].charAt(0).toLowerCase() == 't' ||
Database[x].charAt(0).toLowerCase() == 'u' || Database[x].charAt(0).toLowerCase() == 'w' ||
Database[x].charAt(0).toLowerCase() == 'x' || Database[x].charAt(0).toLowerCase() == 'y' ||
Database[x].charAt(0).toLowerCase() == 'z')
{
// Then just use the letter
let = Database[x].charAt(0).toLowerCase() + '/';
}

// Else if it's a humber,
else if (Database[x].charAt(0) == '1' || Database[x].charAt(0) == '2' ||
Database[x].charAt(0) == '3' || Database[x].charAt(0) == '4' ||
Database[x].charAt(0) == '5' || Database[x].charAt(0) == '6' ||
Database[x].charAt(0) == '7' || Database[x].charAt(0) == '8' ||
Database[x].charAt(0) == '9' || Database[x].charAt(0) == '0')
{
// Use "num"
let = 'num/';
}

// Else,
else
{
// Use "sym" (symbol)
let = 'sym/';
}

// Add the let variable as the folder name and Database[x] as the filename
Result += '' + Database[x] + '

\n';

// It has found a match
hasFound = true;
}
}
}

// If it hasn't found any matches,
if (hasFound == false)
{
// Shout out the worst message you could get on a file search :-)
Result += '0 matches were found.';
}

// Write to the document
this.document.open();
this.document.write(Result);
this.document.close();
}
-----</code>

http://www.xthost.info/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Ruffle Mayo says ROFLMAO! :D


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


javascript run code in an... Confict using two JavaScr...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: JavaScript help please!

Website help! Please! www.computing.net/answers/webdevel/website-help-please/1802.html

Javascript help www.computing.net/answers/webdevel/javascript-help/1284.html

Script, html, telnet coding help re www.computing.net/answers/webdevel/script-html-telnet-coding-help-re/1862.html