Javascript question: Looks easy
Joel Hammer
Joel
Mon May 17 11:35:26 PDT 2004
Well, I solved this myself. It was kinda obvious.
The command replace doesn't replace the original string. Instead, it returns
a new string. So, instead of just:
string.replace(/.*/,"REPLACED")
it should be:
NewString = string.replace(/.*/,"REPLACED")
Being a newbie at anything just isn't much fun.
Joel
On Sat, Jul 20, 2002 at 11:34:13PM -0400, Joel Hammer wrote:
> 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
>
> _______________________________________________
> Linux-users mailing list - http://linux-sxs.org/mailman/listinfo/linux-users
> Subscribe/Unsubscribe info, Archives,and Digests are located at the above URL.
More information about the Linux-users
mailing list