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
    var docprint=window.open("","",disp_setting);
   docprint.document.open();
   docprint.document.write('<html><head><title>Print Plan</title>');
   docprint.document.write("\n");
   docprint.document.write('<STYLE type=text/css media=all>');
   var css = "@import url('css/mystyles.css');";
   docprint.document.write(css);
   docprint.document.write('</STYLE>');
   docprint.document.write("<script language='javascript' src='javascript/zcommon.js' type='text/javaScript'>");
   docprint.document.write("</script>");
   docprint.document.write("<script language='javascript' src='javascript/zplan.js' type='text/javaScript'>");
   docprint.document.write("</script>");
   docprint.document.write('</head><body onLoad="self.print()">');
   docprint.document.write(content_vlue);
   docprint.document.write('</body></html>');
   docprint.document.close();
   docprint.focus();
}

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?
mamusciaAsked:
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.
0
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?
0
Ashish PatelCommented:
So did you try reloading and did it work after reload?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy 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.

bol
0

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.

0
mamusciaAuthor Commented:
thanks
0
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.

bol
0
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
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.