View Full Version : Haunted <textarea>!

06-23-2002, 05:01 AM
This problem only occurs when I do a Refresh to the browser window -- which I only do in testing -- so it really doesn't matter. Except to my sanity.

My hompage consists of a form with a <textarea>. Every time the a visitor returns to the homepage the text is different. Almost every time... there are five sets of text.

This works just fine when you actually leave the homepage and go to any other URL, then return. You find the new text. But if you just do a Refresh -- even a Ctrl Refresh with Internet Explorer -- you see the new text flash in the <textarea> VERY quickly and then the old text appears and stays there.

With each Refresh the text changes as it should but only flashes before the old text re-appears. Again, if you go to a new URL then return the "old text" will be changed.

Here's some code so I don't get asked for it, but I suspect the answer to this will come from someone who better understands how browsers work.

// Texts
if (brType!="MIE"){bl=" \n"} else {bl=""}
text1=bl+"1 Metric? Stones? Kilojoules? See Help";
text2=bl+"2 BMI? BMR? See our FAQs";
text3=bl+"3 See our Frequently Asked Questions (FAQs)";
text4=bl+"4 Check our our Fat Loss Tips";
text5=bl+"5 Check out Diet and Weight Loss Basics";

// Rotate text
if (getCookie("textNumCookie")==null){textNum=1}
else {textNum=getCookie("textNumCookie");
if (textNum > numTexts) textNum=1}
if (textNum==1){text=text1}
if (textNum==2){text=text2}
if (textNum==3){text=text3}
if (textNum==4){text=text4}
if (textNum==5){text=text5}

// Results panel
c+="<tr><td align=center colspan=3>";
c+="<textarea name=results border=1 cols=48 rows="+High+">"+text+"</textarea>";

06-23-2002, 01:46 PM
looking at your code, i noticed the following:

if (getCookie("textNumCookie")==null){textNum=1}
else {textNum=getCookie("textNumCookie");

notice the curly bracket ( '{' ). you have an opening bracket, but not a closing one. i'm guessing that has at least something to do with your problem.

06-23-2002, 03:06 PM
Thanks, but the closing bracket } is down two lines.

The line it appears on looks a little funny because it contains another if statement... one without any {}s because they aren't needed with a simple, one line if statement.

06-23-2002, 03:14 PM
hmm. then maybe if i could see the rest of the page this is on?

06-23-2002, 03:48 PM
Hi joh6nn,

You should be able to see it here: http://nwwellness.com/cph/index.html

Just keep clicking on Refresh and you will see it happen. I numbered the various versions of the <textarea> text to make the error easier to see.

Then click on Fat Loss Tip, slide to the bottom of that page and click on Calculator, and you will see it change as it should.

06-23-2002, 09:08 PM
This is still driving my tired little brain nuts.

I have put an alert message in just after writing the frame. It will display the correct text, which will actually display in the <textarea> in the background. Then when you click on OK, you will see the "ghost" text return.

Variable "c" contains HTML/JS code to create the page:

In addition, I have commented out all of my code which (within functions) changes the <textarea> so I don't see how I can be causing this.

// xxx document.f1.results.value=Results;
// xxx document.f1.results.value=text;
// xxx document.f1.results.value=undoResults;

The only place left that puts text into the <textarea> is when the page is created.

// Results panel (part of form name=f1)
c+="<tr><td align=center colspan=3>";
c+="<textarea name=results border=1 cols=48 rows="+High+">"+text+"</textarea>";

And it looks like this works fine as the correct text appears in the alert, and on the screen before the "ghost" text scares it away!


06-23-2002, 09:27 PM

I had an idea just perusuing your post, so maybe we can assess this before proceeding:

1) which browsers causes this problem (all or NS6/Mozilla & Opera?)
2) has your textarea css style declarations? I ask for I stumbled into strange things made by textarea on the opera and netscape family as a consequence of style declarations.


06-23-2002, 09:32 PM
Dear TrueLies,

Just as you were posting I was trying other browsers. I think my orginal post suggested that it might have to do with that.

The problem doesn't seem to occur with Netscape 6.2 or my WebTV simulator, just Internet Explorer. And I don't have the most recent version of that.

I think I'm going to stop worrying about this now that it works with other browsers and... as I commented originally... it only fails when you Refresh over and over which a visitor will never do.

It was a brain teaser. And a good one!