The fix -- Re: Changing text

by John Starkey <jstarkey(at)advancecreations.com>

 Date:  Tue, 7 Nov 2000 13:55:44 -0700 (MST)
 To:  Jim Coffield <coffield(at)cet.edu>
 Cc:  hwg-languages(at)hwg.org
 In-Reply-To: 
  todo: View Thread, Original
Thanks everyone for the help. The fix is below re: innerHTML. (Thanks
Jim).

I did try outerHTML with a referenced tag and it didn't work so I tried
inner and it did. (Outer may work but I thought I'd try Jim's other
suggestion before I spent too much time on it).

Next time I post I'll try to be a little clearer, sorry about the previous
confusions.

John

On Tue, 7 Nov 2000, Jim Coffield wrote:

> I think I know what your problem is. When you use outerHTML you are
> replacing not only the contents of the element named "name" but also the
> referenced element itself. for example,:
> 
> initial code:
> 
> <p id="name"><font size=+1>help</font></p>
> 
> 
> javascript:
> 
> name.outerHTML="<font size=+2>help</font>"
> 
> 
> result:
> 
> <font size=+2>help</font>
> 
> 
> (without the surrounding <p> tag)
> 
> 
> either include the referenced element tag in the javascript statement:
> 
> name.outerHTML="<p id='name'><font size=+2>help</font></p>"
> 
> 
> or use innerHTML since it only replaces code with the referenced element:
> 
> name.innerHTML="<font size=+2>help</font>"
> 
> 
> 
> I hope this helps
> 
> 
> >I'm sorry it was really late yesterday, after 16 hours of work that I sent
> >this message. To elaborate a little further:
> >
> >I tried several things to get the below to work. And it works fine until
> >the second time around. That's with or without the conditionals. If I put
> >it in a function by itself obviously it isn't going to appear to do
> >anything but it shouldn't send an error saying object doesn't support
> >property or method after it has already performed the task once, proving
> >it's ability to do it.
> >
> >Sorry about the inconvenience. I was adding the below function for
> >simplicity, didn't do very well eh??
> >
> >Thanks,
> >
> >John
> >
> >On Tue, 7 Nov 2000, Jim Coffield wrote:
> >
> >> try the following:
> >>
> >>
> >> function togLit()
> >> {
> >>     if (a==0 || a==1)
> >>     {
> >>         name.outerHTML="<font size=+1>HELLLLP</font>";
> >>         a=2;
> >>     }
> >>     else
> >>     {
> >>         name.outerHTML="<font size=+2>HELLLLP</font>";
> >>         a=1;
> >>     }
> >> }
> >>
> >> >ooops sorry. That was just a typo in this message.
> >> >
> >> >On Tue, 7 Nov 2000, Jeff Adelsberger wrote:
> >> >
> >> >> instead of:
> >> >>   if (a==0 || a=1)
> >> >>
> >> >> try:
> >> >>   if (a==0 || a==1)
> >> >>
> >> >>
> >> >> At 23:51 -0700 11/6/00, John Starkey wrote:
> >> >> >I've been fighting this for two hours. Hep me, hep me???
> >> >> >
> >> >> >I'm trying to toggle a line of text between +1 and +2 using JS.
> >> >> >
> >> >> >function togLit()
> >> >> >{
> >> >> >    if (a==0 || a=1)
> >> >> >    {
> >> >> >        name.outerHTML="<font size=+1>HELLLLP</font>";
> >> >> >        a=1;
> >> >> >    }
> >> >> >    else
> >> >> >    {
> >> >> >        name.outerHTML="<font size=+2>HELLLLP</font>";
> >> >> >        a=2;
> >> >> >    }
> >> >> >}
> >> >> >
> >> >> >It's actually about 80 lines of code total, but well....
> >> >> >
> >> >> >Anyway. The second time around it won't change the outerHTML. Is there a
> >> >> >better way to do this? It seems that
> >>name.outerHTML!="name.outerHTML" once
> >> >> >you've used it. Does it become something else? Like
> >>mod.name.outerHTML or
> >> >> >something, in JS's eyes.
> >> >> >
> >> >> >Thanks,
> >> >> >
> >> >> >John
> >> >>
> >> >> ----------------------------------------
> >> >>                    Jeff Adelsberger
> >> >>                       Programmer
> >> >>                   Dynamic Diagrams
> >> >>                        Baltimore
> >> >>       phone:            410.694.4149
> >> >>       email:    jade(at)dynamicdiagrams.com
> >> >> -----------------------------------------
> >> >>
> >>
> >>
> >>
> 
> 
> 

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.