Jump to content

MS Word Cleanup


phpbeginner

Recommended Posts

I have a CMS with basic toolbar and have major issues with copying and pasting from MS Word.

 

I have a code below that I would like to test cleaning up MS Word....

 

 

<?php
function word_cleanup ($str)
{
    $pattern = "/<(\w+)>(\s| )*<\/\1>/";
    $str = preg_replace($pattern, '', $str);
    return mb_convert_encoding($str, 'HTML-ENTITIES', 'UTF-8');
}
?>

And would like to add it onClick within code below, but it doesn't seem to do anything......

 

 

<?php
//we will have to dynamically generate either the edit and delete buttons or
//the save button here depending on numevent.
if($numMain!=-1)
{
echo("<tr><td colspan='2' align='center'><input type='submit' id='button' name='edit' value='Save Changes' onClick=\"saveChanges('edit'); onClick=\"function('word_cleanup');\"><input type='submit' id='button' name='delete' value='Delete' onClick=\"saveChanges('delete');\"></td></tr></table></form>");
}
else
{
echo("<tr><td colspan='2' align='center'><input type='submit' id='button' name='save' value=' Save ' onClick=\"saveChanges('save'); onClick=\"function('word_cleanup');\"></td></tr></table></form>");
}

?>

 

 

Any help, tips, suggestions would be so greatly appreciated.

Link to comment
Share on other sites

You'll need to either create it as a javascript function (I have no idea what you're attempting is possible in JS), or use AJAX to submit the code to your PHP page. Either way, you'll need javascript help.

The third option I see is instead of doing it onclick, make the page submit, use PHP to clean it up, then refill the form with the corrected content.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.