echo'(if confirm("blah blah - again
Posted: Wed Dec 11, 2002 4:38 am
Is it possible to combine php with dynamic javascript. Or do i need a rethink?
If an entered name is already on the database, then i want to make the user aware of this and give them
the option not to input the data. I have left this verification until after the input form has been submitted.
The problem seems to lie with having a call to a php function mixed in with the Javascript.
I can't get my head round this.
The form has previously been submitted, the data is on the server, so why can't php and java code live in harmony?
I take out the "echo" and the "Addcontacts" and the javascript works.
I leave them and the java don't work but the php does - doh!
Many thanks for help and advice in advance.
// checks if the name is already in the database. If it is already there then
// it return how many times.
if ($NameExists >=1):
echo ' <SCRIPT LANGUAGE="JavaScript" type="text/javascript">
if (confirm("'.$NAME.' already exists in the database '.$NameExists.' times Do you wish to continue?")){ ';
//
echo "<font face=Arial size=+0 color=\"#CC0000\"><b>$NAME has been added to the database</b></font><br>";
AddContacts($FName,$LName,$Spd,$Mbl,$E_M,$WPhone,$Department,$JTitle,$EasyList);
//
echo ' } </script> ';
else:
echo "<font face=Arial size=+0 color=\"#CC0000\"><b>$NAME has been added to the database</b></font><br>";
AddContacts($FName,$LName,$Spd,$Mbl,$E_M,$WPhone,$Department,$JTitle,$EasyList);
endif;
If an entered name is already on the database, then i want to make the user aware of this and give them
the option not to input the data. I have left this verification until after the input form has been submitted.
The problem seems to lie with having a call to a php function mixed in with the Javascript.
I can't get my head round this.
The form has previously been submitted, the data is on the server, so why can't php and java code live in harmony?
I take out the "echo" and the "Addcontacts" and the javascript works.
I leave them and the java don't work but the php does - doh!
Many thanks for help and advice in advance.
// checks if the name is already in the database. If it is already there then
// it return how many times.
if ($NameExists >=1):
echo ' <SCRIPT LANGUAGE="JavaScript" type="text/javascript">
if (confirm("'.$NAME.' already exists in the database '.$NameExists.' times Do you wish to continue?")){ ';
//
echo "<font face=Arial size=+0 color=\"#CC0000\"><b>$NAME has been added to the database</b></font><br>";
AddContacts($FName,$LName,$Spd,$Mbl,$E_M,$WPhone,$Department,$JTitle,$EasyList);
//
echo ' } </script> ';
else:
echo "<font face=Arial size=+0 color=\"#CC0000\"><b>$NAME has been added to the database</b></font><br>";
AddContacts($FName,$LName,$Spd,$Mbl,$E_M,$WPhone,$Department,$JTitle,$EasyList);
endif;