I'm sure a few of us can take a crack at it. However, what you're trying to dol really isn't typical. Hyperlinks should be self-descriptive:
<a href="order_processing.php">Complete your order</a>
"Complete your order" describes what the hyperlink does. Now, I can imagine a scenario where you would like to give your users a fuller explanation of what some hyperlinks do. But physically changing the text of the hyperlink isn't a solution I'd consider. I would
1) set aside an "explanation" portion of the page, perhaps as a element.
2) when the user hovers over a link, change the contents of the element to explain what that link does.
or, alternatively, provide a help system that explains each link, and reference it near the links:
If you're not sure what to do next,
please refer to the <a href="help.html">online help system</a>.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
The main problem you have is understanding variable scope. When you use the keyword "var" INSIDE A FUNCTION, you are declaring that the variable is local, or scoped to that function. That being the case, your "changetext" function cannot access the objects you create in your "creatediscription" function.
Examine the code I have below, which is what you're trying to achieve, I think. I have removed the "var" keyword, making those objects global in scope.
I've also modified the "changetext" function to use "documentGetElementById" and the "innerHTML" property, to illustrate their use.
Have fun!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html> <!--HTML Transitional Javascript Test Page-->
<!--Header Information-->
<head>
<!--Page's Title-->
<title>Test Page</title>
<!--CSS Styling Information-->
<style>
/*Class Specific Styling Information*/
div#navbar
{
background-color: #00FF00;
position: absolute;
top: 0px;
left: 0px;
width: 100%;
}
div#navLinks
{
float: left;
}
div#linkDescriptions
{
background-color: #FFFF88;
margin: 10px 10px 10px 10px;
width: 100%;
}
</style>
<!--Scripting Information-->
<script type="text/javascript">
//Create the Link Descriptions div.
function createdescription()
{
navbar = document.getElementById('navbar')
linkDescriptions = document.createElement('div');
linkDescriptions_textNode =
document.createTextNode('Hover over a menu for a description.');
linkDescriptions.id = "linkDescriptions";
linkDescriptions.appendChild(linkDescriptions_textNode);
navbar.appendChild(linkDescriptions);
}
function changetext()
{
document.getElementById("linkDescriptions").innerHTML = "Test.";
}
</script>
</head>
<!--Body Information-->
<body onload="createdescription();">
<div id="navbar">
<div id="navLinks">
<p>
<a href="#" onmouseover="changetext();">Main</a>
</p>
</div>
</div>
</body>
</html>
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
You never followed-up. Did you my post make sense? How are your JavaScript efforts going?
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37