Problem with field that contains apostrophe.
Hi all the community,
I'm write you to explain a problem that occurs when I want to cancel a student.
I have a window from where a select a student and then I get all his data. If I had to cancel it I press a cancel button and then a transfer his name and his surname to a js function from where I ask for the confirm. It works fine if the surname or the name of student do not contains any apostrophe. If it does the js function does not executes.
This is my button:
<button type="button" id="cance" onclick="cancella('<?php echo $id;?>','<?php echo $name;?>')">Cancella</button>
Where $name contains the name and the surname of the student.
js function:
<script type="text/javascript">
function cancella(arg1, arg2) {
var request;
request = new XMLHttpRequest();
conferma=confirm('Cancel student ' + arg2 +'?');
if (conferma)
{
request.open("GET", "cancellaStudente.php?&a="+arg1, true);
}
request.onreadystatechange = function() {
if(request.readyState == 4) {
var response = request.responseText;
document.getElementById('info4').innerHTML = response;
}
}
request.send(null);
}
</script>
Please, can some one helps me?
Thanks in advance.
Tegatti.