...

View Full Version : Writing text



jmh722
07-07-2005, 04:21 PM
My Problem:
Right now, what I am trying to make happen is whenever a link is pressed, I want function getText(a) to write new text
into the id element “cont” via showPic(), how do I do that?
I’m stumped...

//variables
var jan = "The traditional birthstone for January is Garnet”;
var feb = "The traditional birthstone for February is Amethyst”;


//Javascript
function getText (a) {
document.write(a)

}

function showPic (whichpic, content) {
if (document.getElementById) {
document.getElementById('placeholder').src = whichpic.href;
if (whichpic.title) {
document.getElementById('cont').childNodes[0].nodeValue =
<!--How do I fit getText(content) into here?-->
}
return false;
} else {
return true;
}
}

//Buttons
<a onclick="return showPic(this, jan);return false;"
href="../images/bananas.jpg" title="January - Garnet">January</a>
<a onclick="return showPic(this, feb);return false;"
href="../images/condiments.jpg" title="February - Amethyst">February</a>


//ID “cont”
<td valign="top" id="cont">hello</td>

vwphillips
07-07-2005, 05:52 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
</head>

<body>
My Problem:
Right now, what I am trying to make happen is whenever a link is pressed, I want function getText(a) to write new text
into the id element “cont” via showPic(), how do I do that?
I’m stumped...
<script language="JavaScript" type="text/javascript">
<!--

//variables
var jan = "The traditional birthstone for January is Garnet";
var feb = "The traditional birthstone for February is Amethyst";


//Javascript
function getText (a) {
document.write(a)

}

function showPic (whichpic, content) {
if (document.getElementById) {
//document.getElementById('placeholder').src = whichpic.href;
// if (whichpic.title) {
document.getElementById('cont').childNodes[0].nodeValue = content;
//or
// document.getElementById('cont').childNodes[0].data = content;


// }
return false;
}
else {
return true;
}
}

//-->
</script>
//Buttons
<a onclick="return showPic(this, jan);return false;"
href="../images/bananas.jpg" title="January - Garnet">January</a>
<a onclick="return showPic(this, feb);return false;"
href="../images/condiments.jpg" title="February - Amethyst">February</a>


<p valign="top" id="cont" >hello</p>
jmh722 is offline Reply With Quote
<script language="JavaScript" type="text/javascript">
<!--
showPic ('',feb)
//-->
</script>
</body>

</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum