Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 2nd, 2005, 1:47 AM   #1
TheShadow
Newbie
 
Join Date: Oct 2004
Posts: 11
Rep Power: 0 TheShadow is on a distinguished road
Whats wrong with this?

Quote:
<script type="text/JavaScript" src="here.js">
<!--
function output() {
var i = Math.round(5*Math.random());
document.write(safetyTips[i]);
}
output();
//-->
</script>
safetyTips[] - this array is in here.js ...
TheShadow is offline   Reply With Quote
Old Apr 2nd, 2005, 8:36 AM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
Your code looks fine, my only suggestion would be to use code like the one i have below to determine if there is anything in the array...

window.onload = function() {
    var length = safetyTips.length;

    if(length == 0)
        document.write("There was an error with the safetyTips array, aborting.");
    else
        document.write(safetyTips[Math.floor(Math.random()*length)]);
}
tempest is offline   Reply With Quote
Old Apr 3rd, 2005, 8:48 PM   #3
TheShadow
Newbie
 
Join Date: Oct 2004
Posts: 11
Rep Power: 0 TheShadow is on a distinguished road
Quote:
<script type="text/JavaScript">
<!--
function index()
{
if (status[2] == "Empty")
{
location = "monitor.html";
}
else
{
alert("Furnace isnt empty");
}
//-->
</script>
<p>
<input type="button" name="empty" onClick="index()" value="Empty?" /></p>
whats wrong with this than?
TheShadow is offline   Reply With Quote
Old Apr 3rd, 2005, 9:35 PM   #4
TheShadow
Newbie
 
Join Date: Oct 2004
Posts: 11
Rep Power: 0 TheShadow is on a distinguished road
Changed it to this ...
Quote:
<script type="text/JavaScript">
<!--

function index()
{
if (status[0] == "Empty")
{
document.location.href = "monitor.html";

} else {

window.alert("Furnace isnt empty");
}
}
//-->
</script>
<p>
<input type="button" name="empty" onClick="index()" value="Empty?" /></p>
Though everything seems to be going to "monitor.html", not just when status[0] == "Empty", is there something wrong with my IF statement?

Quote:
if (status[0] == "Empty")
{
document.location.href = "monitor.html";
TheShadow is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC