rsammy Posted April 11, 2008 Share Posted April 11, 2008 i am not sure if this is where i need to ask this question. i am sorry, if this is not the right place. would appreicate help anyways... i am working with a php application. i need to compare two sets of names (first name, mid init and last name). if they are same, i need to pop-up a javascript alert box saying you are about to merge the info of these two patients - display their names. all works fine. only, this javascript pop-up box part does not show up when the name has an apostrophe(say somethign like Mc'Millan). could someone help me out please? its quite urgent. here is the part where it fails: echo("var answer = confirm('You are attempting to assign a Patient # that is already assigned to an existing patient in the InstiComm system. Entered Patient # already exists! The new patient you just entered is:\\n\\n Name: " .$PatientFirstName . " " .$PatientMiddleInitial . " " .$PatientLastName." \\n Patient #: " .$SavedSSN . " \\n Date of Birth: " .$PatientDOB . " \\n Enter Date: " .$PatientRegDate . "\\n\\nYou can choose to: \\n\\n a) Return to the previous screen and make a correction to the entered Patient # or, \\n b)Merge information of the two patients and losing all Patient Registration information pertaining to the patient displayed above, retaining \\n any ICN\'s/Encounters.\\n\\nThe resulting patient \'status\' will be \'Active\' if one of the merged patients is in the \'Active\' or \'Follow\' state. It will result in \'Not Active\' if both of the merged patients are \'Not Active\' or \'Do Not Follow\'. \\n\\nTHIS PATIENT WILL NO LONGER EXIST IN THE InstiComm SYSTEM.\\n\\nInformation pertaining to patient listed below will overwrite all information except the earliest Enter Date, pertaining to patient displayed at the top of this message. The patient already in the InstiComm system with entered patient # is:\\n\\n Name: " .$dbfname . " " . $dbmidinit . " " . $dblname ."\\n Patient #: " .$dbssn . "\\n Date of Birth: " .$dbdob . " \\n Enter Date: " .$dbregdate . "\\n\\n Click on OK to replace patient information(above) with new patient information(below) or, \\n CANCEL to go back and change the Patient # whose information you wish to update!\\n\\n*** CLICKING ON OK WILL DELETE ALL EXISTING PATIENT REGISTRATION INFORMATION BELONGING TO PATIENT DISPLAYED\\n AT THE TOP BUT RETAIN ALL PATIENT ICNs/ENCOUNTERS. THE RESULTING PATIENT \'STATUS\' WILL BE ACTIVE IF ONE OF\\n THE MERGED PATIENTS IS IN THE \'Active\' OR \'Follow\' STATE. IT WILL RESULT IN \'Not Active\' IF BOTH OF THE MERGED\\n PATIENTS ARE \'NOT ACTIVE\' OR \'Do Not Follow\' *** ');"); any help will be appreciated. this is really really urgent! Quote Link to comment https://forums.phpfreaks.com/topic/100691-solved-problem-with-apostrophe-in-name-field/ Share on other sites More sharing options...
GingerRobot Posted April 11, 2008 Share Posted April 11, 2008 Use the htmlentities() funtion on all of your variables. The problem occurs because the single quotes confuse javascript - they close the string being used for the confirm box. The function will convert the quotes to their HTML character codes. Quote Link to comment https://forums.phpfreaks.com/topic/100691-solved-problem-with-apostrophe-in-name-field/#findComment-514957 Share on other sites More sharing options...
rhodesa Posted April 11, 2008 Share Posted April 11, 2008 That won't do it...use addslashes() Quote Link to comment https://forums.phpfreaks.com/topic/100691-solved-problem-with-apostrophe-in-name-field/#findComment-514960 Share on other sites More sharing options...
GingerRobot Posted April 11, 2008 Share Posted April 11, 2008 That won't do it...use addslashes() Sorry yes, i made a mistake it my testing of it. Wasn't sure if the alert would show the character code or the quote - turns out its the character code. So yes, addslashes() is the way to go. Quote Link to comment https://forums.phpfreaks.com/topic/100691-solved-problem-with-apostrophe-in-name-field/#findComment-514963 Share on other sites More sharing options...
rsammy Posted April 11, 2008 Author Share Posted April 11, 2008 thanx a millions ginger and rhodesa! you solved my problem. wonderful guyz Quote Link to comment https://forums.phpfreaks.com/topic/100691-solved-problem-with-apostrophe-in-name-field/#findComment-514985 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.