phpbeginner Posted March 30, 2012 Share Posted March 30, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260008-ms-word-cleanup/ Share on other sites More sharing options...
Jessica Posted March 30, 2012 Share Posted March 30, 2012 You're mixing PHP and javascript. They don't work like that. Quote Link to comment https://forums.phpfreaks.com/topic/260008-ms-word-cleanup/#findComment-1332706 Share on other sites More sharing options...
phpbeginner Posted March 30, 2012 Author Share Posted March 30, 2012 Any idea how I can add the cleanup code onClick? Quote Link to comment https://forums.phpfreaks.com/topic/260008-ms-word-cleanup/#findComment-1332707 Share on other sites More sharing options...
Jessica Posted March 30, 2012 Share Posted March 30, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260008-ms-word-cleanup/#findComment-1332708 Share on other sites More sharing options...
phpbeginner Posted March 30, 2012 Author Share Posted March 30, 2012 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/260008-ms-word-cleanup/#findComment-1332710 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.