PDA

View Full Version : looking for a simple script


lithium
03-08-2003, 11:53 PM
I need a simple script that would replace one word about 11 times throughout a document, depending on input from the person viewing the page.

It would be the same word, replaced with one single word throughout.

I have looked everywhere for a script to do this with no luck.

Anyone know where I can find such a beast?

Thanks!

Mhtml
03-09-2003, 12:19 AM
Woah, that's quite a request.

This can be done via server side scripting easily but I'm not so sure about javascript.

Philip M
03-09-2003, 08:28 AM
tmpStr=frmObj.value;
tmpStr = tmpStr.replace ( /badword\b/gi, "goodword" );
frmObj.value = tmpStr;

Or have I misunderstood what is wanted?

Reading lithium's request once again, I now see that he means in an HTML document. Does he want to (say) personalise the page so it says something like "Hello John" or "Hello Peter" depending on what user name the visitor enters into a textbox?

lithium
03-09-2003, 10:14 AM
Yep Philip, that's what I am going for.

A name throughout a medium length body of text would be changed depending on the input of the user.

Sorry, the first post wasn't quite clear! tnx

Philip M
03-09-2003, 11:30 AM
The nearest I can find is at

http://javascript.internet.com/messages/name-write.html

This may or may not be what you are looking for.

FJbrian
03-10-2003, 07:14 AM
just use an html form and pass the form value's along

Like textbox value=whatever
then when they submit have the javascript
write the same value into a form textbox amidst your story.

lithium
03-10-2003, 10:30 AM
thanks Philip, I think that may just work!

JavaRookie
03-10-2003, 01:12 PM
Is it possible to ask someone's name and store it in a cookie, so the next time this 'someone' visits your site it displays the same name? Of course it is, but can anyone tell me how? I cannot figure out these cookie-things! :confused: :)