473,659 Members | 2,929 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 4615
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.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

"Randy Webb" <Hi************ @aol.com> wrote in message
news:ko******** ************@co mcast.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.javas cript FAQ - http://jibbering.com/faq


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

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

then in the body of the html:

input type="submit" value="click" onclick="change it('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(myChan ge)
{ //alert('here ' + myChange);
// status = myChange; document.getEle mentById("t1"). innerHTML = myChange;
}


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

document.getEle mentById("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(myChan ge){
//alert('here ' + myChange);
// status = myChange;
document.getEle mentById("t1"). innerHTML = myChange;
}

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

Fred.
Jul 23 '05 #4

"Fred Oz" <Oz****@iinet.n et.auau> wrote in message
news:_H******** ******@news.opt us.net.au...
Oxnard wrote:
function changeit(myChan ge)
{ //alert('here ' + myChange);
// status = myChange; document.getEle mentById("t1"). innerHTML = myChange; }


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

document.getEle mentById("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(myChan ge){
//alert('here ' + myChange);
// status = myChange;
document.getEle mentById("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.getEle mentById("t1"). innerHTML = myChange;
was on a line by itself.
I remove the commented out lines:

function changeit(myChan ge){
document.getEle mentById("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="change it('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.n et.auau> wrote in message
news:iD******** *******@news.op tus.net.au...
Oxnard wrote:
[snip]
then in the body of the html:

input type="submit" value="click" onclick="change it('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
2629
by: Otto Porter | last post by:
/*Given*/ CREATE TABLE ( IDENTITY (1, 1) NOT NULL , NULL , (2) NULL , NULL , CONSTRAINT PRIMARY KEY CLUSTERED (
1
2242
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 the datagrid is clicked, but is erroring out the page when I click page 2,3,etc. I have tried a few different notations without any luck. Can someone look at the lines below and tell me what might be wrong? Thanks in advance! 'event being...
6
2887
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 de maan" /> Now I would like to indicate that the phrase 'De reis naar de maan' is Dutch, for the profit of users with a screen reader and others who may benefit from it. Unfortunately I can't use a <span lang="nl"> inside the alt attribute. I...
0
1844
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 without any luck. Can someone look at the lines below and tell me what might be wrong? Thanks... 'event to change page: Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As...
0
1215
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" runat="server" style="color:#FF0000" Text="Submit Answer" OnClick="submitAnswer_click" onInit="submitAnswer_onInit" OnLoad="submitAnswer_onLoad" OnPreRender="submitAnswer_onPreRender" OnUnload="submitAnswer_onUnload"...
3
15131
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, but am finding it a little difficult as there isn't a simple property to set. Thanks, Rog
8
1835
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
9625
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 element and change its color from the parent element if possible. <script type="text/javascript"> function HightLightCell(mycell, mybgcolor) { mycell.bgColor=mybgcolor; }
1
1483
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 column in datagride also change and be equal to new value entered inside textbox. But this change reflects to datagrid just when I change selected row in the datagrid.
18
7761
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 messages to be displayed, the other button collapses that same thread. Works fine. I was asked if I can just make it one button. I've played around with a few java scripts. they seem to all work fine until i put my added codes in the text line...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8629
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7360
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4176
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.