Javascript help
#1
Scooby Regular
Thread Starter
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes
on
0 Posts
Javascript help
Evening chaps.
Here's one for all you javascript types.
Here's an HTML page element:
What I want to be able to do, via javascript is to replace the text part of the field, iel change "Text I Want to replace" to anything I like (I'll actually be getting the text from within the JS)
How can I do this?
I am replacing images from JS with no problem, for example:
I can change the SRC of the above in JS by simply doing this:
So I guess it can be done, correct?
Here's one for all you javascript types.
Here's an HTML page element:
Code:
<a id="locationareatext" name ="thenewtextarea"/>Text I want to replace</a>
How can I do this?
I am replacing images from JS with no problem, for example:
Code:
<img id="selectionbuttons" src='Images/dvp.png' name ="dvp">
Code:
sourcea = "Images/gardiner_s.png"; document["gardiner"].src = sourcea;
#2
Scooby Regular
Thread Starter
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes
on
0 Posts
Wise man say "If you use correct search terms, then enlightenment you will find!"
Seems I can do away with the < a > thing, simply specify it as a < div >
then simply have < div ID="nameofitem" >
then in my JS I can use:
lovely
Seems I can do away with the < a > thing, simply specify it as a < div >
then simply have < div ID="nameofitem" >
then in my JS I can use:
Code:
document.getElementById('thedivid').innerText = "the new text";
#4
Simple example of changing span contents: (copy and paste into filename.html)
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function displaydatetime()
{
if (!document.layers && !document.all) return;
var today;
var timeLocal;
today = new Date();
timeLocal = today.toLocaleString(); //Convert to current locale.
if (document.layers)
{
document.layers.clockLocal.document.write(timeLoca l);
document.layers.clockLocal.document.close();
}
else if (document.all)
{
clockLocal.innerHTML = timeLocal;
}
setTimeout("displaydatetime()", 500)
}
window.onload = displaydatetime;
</script>
</head>
<body>
<span id=clockLocal style="position:relative;"></span>
</body>
</html>
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function displaydatetime()
{
if (!document.layers && !document.all) return;
var today;
var timeLocal;
today = new Date();
timeLocal = today.toLocaleString(); //Convert to current locale.
if (document.layers)
{
document.layers.clockLocal.document.write(timeLoca l);
document.layers.clockLocal.document.close();
}
else if (document.all)
{
clockLocal.innerHTML = timeLocal;
}
setTimeout("displaydatetime()", 500)
}
window.onload = displaydatetime;
</script>
</head>
<body>
<span id=clockLocal style="position:relative;"></span>
</body>
</html>
Thread
Thread Starter
Forum
Replies
Last Post
CodeKey@Lisan
Computer & Technology Related
11
20 February 2004 05:23 PM
RichB
Computer & Technology Related
2
05 November 2003 02:27 PM