Running PHP code into JavaScript if-else clause
| From: | Wagner Marini | Date: | Mon, 11 Nov 2002 18:06:39 +0000 |
| Subject: | Running PHP code into JavaScript if-else clause | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-123863@lists.php.net to get a copy of this message | ||
JavaScrip and PHP together
Hey ALL,
I really do not understand what's going on.
In my code below I try to inform the user that the number added to him
already exists in database but in my JavaScrit's if-else the line "<?php
$tst = TRUE; ?>" ever run, even the user wants to add the number.
What's happened??
Thanks,
WMarini/
----------------------------------------------------------------------------
---
...
<body>
<?php
$tst = FALSE;
...
$contact_ins = "insert into contato (nome) values ('$name');";
mysql_query( $contact_ins ) OR die( mysql_error() );
//Check if numero exists.
if( CheckNumber( $numero ) ) {
?>
<script language="JavaScript">
if ( window.confirm("Number to be added exists.\nContinue?") ) {
//The user wants to add the number defined.
<?php $tst = FALSE; ?>
break;
}
else { //User does not want to add the number.
<?php $tst = TRUE; ?>
;
}
</script>
<?php
}
if( $tst == FALSE ) {
//Add the number, Don't care!
...
}
...
?>
</body>
</html>
----------------------------------------------------------------------------
---
--
Wagner Marini ----