Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 15th, 2005, 06:22 AM
Registered User
 
Join Date: Jul 2005
Location: Elgin, IL, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Transferring a variable value

I'm currently attempting to show a scrolling marquee when the value of my variable doesn't read "NO CURRENT ADVISORIES". If other than that, it will scroll a message, allowing the user to click on the marquee and a new web page will be displayed.
My variable is in an xml file, and I'm using the "document.getElementById" statement. It is reading the xml just fine. I'm not sure of the code needed transferring "message" to my IF statement.
I'm not having any success doing it.:(
(The div id statement is being used as a test making sure I'm pulling the xml value correctly, and it is working.)

Code:
<html>
<head>
<script type="text/javascript">
var xmlDoc
function loadXML()
{
//load xml file
// code for IE
if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("http://www.jlocon.com/wdfulldata.xml");
getmessage()
}
// code for Mozilla, etc.
else if (document.implementation &&
document.implementation.createDocument)
{
xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("http://www.jlocon.com/wdfulldata.xml");
xmlDoc.onload=getmessage
}
else
{
alert('Your browser cannot handle this script');
}
}function getmessage()
{
document.getElementById("message").innerHTML=xmlDoc.getElementsByTagName("noaaw")[0].firstChild.nodeValue;
}
<!--
if (message != "NO CURRENT ADVISORIES")
      {
       document.write("<table border='1' cellpadding='0' cellspacing='0' width=550 bgcolor='RED'><tr><td><a 

href='http://www.jlocon.com/laridx.htm'><marquee scrolldelay='125' 

width='550'>NORTHERN ILLINOIS-CHICAGO AREA - WEATHER WARNING ISSUED ... [Click here for details]

</marquee></a></td></tr></table><br>");}
//-->
</script>
</head>
<body onload="loadXML()">
<div id="message" style="background-color:pink"></div>

</body>
</html>

Lar
Reply With Quote
  #2 (permalink)  
Old July 17th, 2005, 06:31 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

When you retrieve your content store it:
Code:
var sContent = xmlDoc.getElementsByTagName("noaaw")[0].firstChild.nodeValue;
then test it against "NO CURRENT ADVISORIES"
Code:
if (sContent == "NO CURRENT ADVISORIES")
{
  //display no advisory message
}
else
{
  //write marquee
}
--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old July 17th, 2005, 08:29 AM
Registered User
 
Join Date: Jul 2005
Location: Elgin, IL, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe;
Thank you kindly for the update, I've made the change and it works ok as a standalone.
Now the next phase. Why when I put this into a regular html page, that it will register either condition and then open a brand new page? I thought it would just write it on the same page where the coding is located. Any suggestions there?

Lar
Reply With Quote
  #4 (permalink)  
Old July 19th, 2005, 02:26 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You can only "document.write" to an open page, one that has not finished loading and rendering. To adjust content after loading there are many options but the most standard is to use the innerHTML property. For example if you have a div with an id of "divMessage" then to change this:
Code:
<div id="divMessage">Hello world</div>
to this:
Code:
<div id="divMessage">Hello Lar</div>
use this script:
Code:
var oMessageDiv = document.getElementById("divMessage");
oMessageDiv.innerHTML = "Hello Kar";
So you need to set up a div or a span to hold your marquee element.

As a side issue there's not much point worrying about cross browser compatibility with your code as "marquee" is IE only.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #5 (permalink)  
Old July 19th, 2005, 05:03 AM
Registered User
 
Join Date: Jul 2005
Location: Elgin, IL, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Joe,
Thanks again for your input. You're working with a newbie to JS and I'm not grasping where to put that type of a statement within my codeing. I understand what you're saying, but the coding is the question, any help there?

Lar
Reply With Quote
Reply


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Transferring files sachtaridis Visual C++ 0 November 22nd, 2007 07:31 AM
transferring/copying from spreadsheet to another Aprile Excel VBA 2 September 7th, 2007 07:16 AM
Transferring Dlls from one server to another Pallavs20 General .NET 0 October 13th, 2005 03:13 AM
Transferring data between functions Fightfish C# 2 July 6th, 2005 01:21 PM
Transferring Import Specifications timmaher Access 4 September 1st, 2003 11:58 AM



All times are GMT -4. The time now is 12:34 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.