Javascript Replace Method on innerHTML

I am trying to replace certain character strings found in the innerHTML and then once changed, write it out to a new HTML page.  
Here is my function which I invoke from a button onClick event:
function printPlanList(id) {
    var disp_setting="toolbar=no,location=no,directories=no,menubar=no,";
    disp_setting+="scrollbars=yes,width=820, height=450, left=100, top=25";
    var content_vlue = new String(eval("document.getElementById('"+id+"').innerHTML"));
    content_vlue.replace(/assignpicn/g, "assignpicp");  // make pics visible
    content_vlue.replace(/ztextview/g, "clickDummy");   // disable visibility function
    content_vlue.replace(/button/g, "hidden");          // make buttons invisible
   docprint.document.write('<html><head><title>Print Plan</title>');
   docprint.document.write('<STYLE type=text/css media=all>');
   var css = "@import url('css/mystyles.css');";
   docprint.document.write("<script language='javascript' src='javascript/zcommon.js' type='text/javaScript'>");
   docprint.document.write("<script language='javascript' src='javascript/zplan.js' type='text/javaScript'>");
   docprint.document.write('</head><body onLoad="self.print()">');

It is working to open the new window and to write the contents, except the REPLACE methods I am using does not change any of the string text I want.  Any ideas on how to perform this function?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ashish PatelCommented:
Yes please reload the window document again and it should come.
mamusciaAuthor Commented:
I don't understand your answer.  I am changing the contents of the HTML prior to writing it to the new window so when I do the writes it should be the changed text already.  I'm not sure why the Javascript replace method isn't working on the string contents I put into the content_vlue string from the innerHTML contents.  

Why does it only work if I Reload the page?
Ashish PatelCommented:
So did you try reloading and did it work after reload?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

b0lsc0ttIT ManagerCommented:
I see one error in what you have ...

    content_vlue = content_vlue.replace(/assignpicn/g, "assignpicp");  // make pics visible
    content_vlue = content_vlue.replace(/ztextview/g, "clickDummy");   // disable visibility function
    content_vlue = content_vlue.replace(/button/g, "hidden");          // make buttons invisible

Let me know how that change works.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mamusciaAuthor Commented:
I did try ReLoad and the same HTML is present and no changes were made to the HTML string contents.

Geeze - how dumb.  I did the solution that you outlined and it works like a charm.  I needed to assign the value of content_vlue to the new value after replacing the strings.

mamusciaAuthor Commented:
b0lsc0ttIT ManagerCommented:
:D  Your welcome!  It is an easy mistake to make, especially if you usually write the result of the replace() or use other languages.

I'm glad I could help.  Thanks for the grade, the points and the fun question.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.