Hello,


I've a problem with php and javascript.

With a tool, I put some data in a database.

The I've a form. In this form I want t o load the saved data from the database.

With javascript I open a popup, from where you can choose the right entry.
If the entry is chosen, the popup will be closed en you return to the form, now filles with your data.

This all works perfect, except at 1 point.

If the text in the database contains a hard return, the javascript doesn't work and errors that the strig isn't closed.

this is my code:
Main:
PHP
<script language="JavaScript">
<!--
function selectItem(){
var selindex=document.myForm.myselect.selectedIndex;
if (selindex!=0) {document.myForm.titel.value=document.myForm.myselect[selindex].value;}
}

var wi=null;
function popUp(){
if (wi) wi.close();
wi=window.open("popup.php","","width=800,height=600,location=yes,scrollbars=no,status=yes");
}
//-->
</script>


Pop-up:
PHP
<script language="JavaScript">
<!--
function selectItem(value){
var selindex
selindex = value;
if (selindex!=0) {
window.close();
window.opener.document.myForm.titel.value=selindex;
}
}
//-->
</script>
<?PHP

if(!empty($_POST["myselect"]))
{
$query = "SELECT Profiel FROM DOORSCHAKELCLUB WHERE Boxnummer = '". $_POST["myselect"] ."'" ;
$profiel = mysql_query($query);
list($_POST["titel"]) = mysql_fetch_row($profiel);
print_r(htmlspecialchars($_POST["titel"]));
?>
<script LANGUAGE="JavaScript">
selectItem('<?=htmlspecialchars($_POST["titel"])?>');
</SCRIPT>
<?PHP
}
before the return you have to set an /
write a script that set an / before al ' in your database

like this:

doesn't

=

doesn/'t
You can filter all the \n and \r from the text with str_replace( , , );
Ì know but i need the \n later, so i can't just replace it
And maybe a stupid reminder. But this a Dutch forum not a engelish one :/
En waarom is die query dan zo: SELECT Profiel FROM DOORSCHAKELCLUB WHERE Boxnummer =

ziet er nederlands uit !
en een engelse die wel ned kan lezen, en dirk heet, is ie dan engels?
lol, dezelfde post op een engels forum geplaatst.

ctrl-c ctrl-v.............

Reageren