Integrated PHP and Javascript
Posted: Fri Mar 16, 2007 7:36 am
Hi guys,
In my PHP page, I have 1 Javascript function to compare the value of the textbox with the value in database. In my opinion I have to use PHP in my Javascript function. PHP will be used to retrieve data from database and it will be compared to the value of the textbox (document.form1.txtTest.value;) in my Javascript function. The problem is I don't know how to do it. It always get error. Anybody can help me pls? Thanks.
Example of Javascript function:
function test() {
<?php
$a = ?>document.form1.txtTest.value; <?php ;
?>
alert('<?php echo $a ?>');
}
In my PHP page, I have 1 Javascript function to compare the value of the textbox with the value in database. In my opinion I have to use PHP in my Javascript function. PHP will be used to retrieve data from database and it will be compared to the value of the textbox (document.form1.txtTest.value;) in my Javascript function. The problem is I don't know how to do it. It always get error. Anybody can help me pls? Thanks.
Example of Javascript function:
function test() {
<?php
$a = ?>document.form1.txtTest.value; <?php ;
?>
alert('<?php echo $a ?>');
}