Old 12-11-2005   #1 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
javascript problem: replace()

Code:
function updateTextarea(textareaName, fieldName){

        var currentValue = document.getElementById(textareaName).value;
        var currentName  = document.getElementById(fieldName).value;

        var replacer = "[yourname]";
        var newValue = currentValue.replace(replacer, currentName);

        // replacer = currentName;

        document.getElementById(textareaName).value = newValue;

        // make the fields inactive now

        document.getElementById(fieldName).disabled = true;
        document.getElementById("setButton").disabled = true;

}
what i want to do is this: i have a textarea called "message" and a input field called "name" with a button next to it called "setButton" which you click on, and it replaces the instance of "[yourname] in the "message" textarea with the value of the "name" text field, and then proceeds to make the "name" and "setButton" elements disabled so you can't replace again.

my problem is that this works exactly how i want it to in IE, but neither parts of the functionality work in firefox (haven't tried Opera or safari yet)

any help?
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-12-2005   #2 (permalink)
Moderator
 
Join Date: Jul 2004
Location: Quebec City, Canada
Posts: 50

Have you tried with something more like this?

Code:
var replacer = /\[yourname\]/gi;
Also, make sure that both your textarea and input elements have IDs and not only names
The Eagle is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-12-2005   #3 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
cheers. i will try that
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XHTML Coding problem bana HTML / PHP / ASP / JS 6 12-21-2005 12:24 AM
sound card problem? scrowler General Discussions 4 12-12-2005 08:09 PM
How can i combine Javascript with PHP? ParaSnake HTML / PHP / ASP / JS 2 06-29-2005 01:46 PM
Chicken & The Egg Problem! Man1c M0g HTML / PHP / ASP / JS 3 04-05-2005 07:02 PM
redhat problem Milkdrop General Discussions 3 12-14-2003 07:05 AM


All times are GMT +1. The time now is 09:18 AM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT