Javascript question: Looks easy

Joel Hammer Joel
Mon May 17 11:35:12 PDT 2004


I am a javascript newbie, and I hate javascript, but...
I made more progress today then I dared hope. That is, I got done in a days
work what should have taken about two hours.
Hmmmm....
Anyway,

I am writing out lines of a form to a new window with javascript.
It is looking good but:
I need to replace various strings in the original form with new strings.
However, try as I might, I can't get anything replaced.

Here are the commands of interest.

  form[i].value.replace(/.*/,"REPLACED");
  msg.document.write(form[i].value);          

The first command tries the replacement, The second command prints out the
line to the new page.
Nothing seems to happen as far as replacing the old text.
I tried to substitute another variable for form[i].value, eg.

  var jj = form[i].value
  jj.replace(/.*/,"REPLACED");
  msg.document.write(jj);          

but that didn't do anything.


Any insight really appreciated,

BTW, if you don't have to do it, don't program in javascript. What nonsense.
For example, netscape 6.2 (linux) barfs on the command typeof, which first appeared
in netscape 3. This has taken me about an hour to figure out. That's what
happens when the book is wrong. In fact, Netscape 6.2 chokes on trying to
display or even examine any undefined value. Gaaaaaaadds.

Joel




More information about the Linux-users mailing list