473,508 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change what is inside a tag

if I have some text inside a tag like:

<div id="test" >
stuff I want changed
</div>

how can I change it to something else:
<div id="test" >
my new text
</div>

using a javascript fuction which I call elsewhere in the page?


Jul 23 '05 #1
6 4607
Oxnard wrote:
if I have some text inside a tag like:

<div id="test" >
stuff I want changed
</div>

how can I change it to something else:
<div id="test" >
my new text
</div>

using a javascript fuction which I call elsewhere in the page?


Read the group FAQ, linked in the signature. Especially section 4.15
since it answers that exact question.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

"Randy Webb" <Hi************@aol.com> wrote in message
news:ko********************@comcast.com...
Oxnard wrote:
if I have some text inside a tag like:

<div id="test" >
stuff I want changed
</div>

how can I change it to something else:
<div id="test" >
my new text
</div>

using a javascript fuction which I call elsewhere in the page?


Read the group FAQ, linked in the signature. Especially section 4.15
since it answers that exact question.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq


I know I *think* I did follow the faq here is the html:

function changeit(myChange)
{ //alert('here ' + myChange);
// status = myChange; document.getElementById("t1").innerHTML = myChange;
}

then in the body of the html:

input type="submit" value="click" onclick="changeit('sds')"
dev id="t1">blah blah</dev

Note: I had to leave off the < & > as Outlook Express wanted to treat it as
html.

for some reason the text 'blah blah' does not change to 'sds'.

I am using IE 6.0.288

Thanks


Jul 23 '05 #3
Oxnard wrote:
function changeit(myChange)
{ //alert('here ' + myChange);
// status = myChange; document.getElementById("t1").innerHTML = myChange;
}


Perhaps you should un-comment some part of the function? Perhaps put:

document.getElementById("t1").innerHTML = myChange;

on a line by itself?

It's not good style to put multiple statements on the same line, it's
far better to put one statement per line to make the code more
readable, so your function would become (with debug comments intact):

function changeit(myChange){
//alert('here ' + myChange);
// status = myChange;
document.getElementById("t1").innerHTML = myChange;
}

Also read the thread below: "Changing <p> text on the fly".

Fred.
Jul 23 '05 #4

"Fred Oz" <Oz****@iinet.net.auau> wrote in message
news:_H**************@news.optus.net.au...
Oxnard wrote:
function changeit(myChange)
{ //alert('here ' + myChange);
// status = myChange; document.getElementById("t1").innerHTML = myChange; }


Perhaps you should un-comment some part of the function? Perhaps put:

document.getElementById("t1").innerHTML = myChange;

on a line by itself?

It's not good style to put multiple statements on the same line, it's
far better to put one statement per line to make the code more
readable, so your function would become (with debug comments intact):

function changeit(myChange){
//alert('here ' + myChange);
// status = myChange;
document.getElementById("t1").innerHTML = myChange;
}

Also read the thread below: "Changing <p> text on the fly".

Fred.


the text did not format quite right in OE. The statement:
document.getElementById("t1").innerHTML = myChange;
was on a line by itself.
I remove the commented out lines:

function changeit(myChange){
document.getElementById("t1").innerHTML = myChange;
}

this did not work.
If I put the line:
alert('myChange ' + myChange);
as the first line in the function I see what I am passing to the function,
however if I put it after the innerHTML line the dialog box never appears.
It seems I see an error on status message in IE but it goes by quickly. How
can I see what the error is?


Jul 23 '05 #5
Oxnard wrote:
[snip]
then in the body of the html:

input type="submit" value="click" onclick="changeit('sds')"
dev id="t1">blah blah</dev
[snip]
this did not work.


Perhaps because you have a <dev> tag, not a <div> tag. Firefox will
tolerate the <dev> tag in quirks mode, IE does not.

Fred.
Jul 23 '05 #6

"Fred Oz" <Oz****@iinet.net.auau> wrote in message
news:iD***************@news.optus.net.au...
Oxnard wrote:
[snip]
then in the body of the html:

input type="submit" value="click" onclick="changeit('sds')"
dev id="t1">blah blah</dev

[snip]

this did not work.


Perhaps because you have a <dev> tag, not a <div> tag. Firefox will
tolerate the <dev> tag in quirks mode, IE does not.

Fred.


After taken a break I got it. Additioning I missed putting a closing > else
where in the page.
Thank you for your time.
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2618
by: Otto Porter | last post by:
/*Given*/ CREATE TABLE ( IDENTITY (1, 1) NOT NULL , NULL , (2) NULL , NULL , CONSTRAINT PRIMARY KEY CLUSTERED (
1
2224
by: Mad Scientist Jr | last post by:
I am getting an error in my code that references a textbox inside the current row of my datagrid, whenever I try changing the page (paging is enabled). This code doesn't even run unless a button in...
6
2869
by: Garmt de Vries | last post by:
On some of my English language webpages, I have images of Dutch books. In the alt text for this image, I give the title of the book, for example: <img src="maan.jpg" alt="Cover of De reis naar...
0
1835
by: Mad Scientist Jr | last post by:
I am getting an error in my code that references a textbox inside the current row of my datagrid, whenever I try changing the page (paging is enabled). I have tried a few different notations...
0
1207
by: tshad | last post by:
I am trying to figure out how to handle a couple of problem using multiple events tied to the same button. Following is the button: <asp:button ID="submitAnswer" CommandName="SubmitAnswer"...
3
15110
by: Roger | last post by:
Is this an easy thing to change? I want to put an option button on a form and want to dynamically change the color (Red, Yellow, Green) for showing a status. I figured it would be an easy task,...
8
1827
by: Maxi | last post by:
Hello, i'm sorry my bad english :( I have CR9 Webservice, how to change databadse name and User_name into Webservice method? (not Viewer Control) Tks!! -- --------------------------
3
9616
by: rlueneberg | last post by:
I want to change the color of an "a" child element inside a table cell via javascript. Is there any way to do that? Ps: there is no id assigned to child elements. I would like to discover the child...
1
1478
by: AliRezaGoogle | last post by:
Dear members, I have a datagrid and a textbox on my form. I bound both of them to a common datasource( an arbitrary datatable). When I change a text inside textbox I expect that value of same...
18
7727
by: wizdom | last post by:
Help - change text on click - text has another onclick inside with php variables ---------- I think what I'm trying to do is simple. I have a 2 buttons on a page. 1 button allows a thread of...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.