Then I would suggest doing one of two things. Either use ajax and have it return the value you need or do something like this
PHP Code:
<?php
$firstname = query database for first name
?>
<script type="text/javascript">
function compare() {
var databasefield = '<?php echo $firstname; ?>';
}
</script>
If you are checking more then one value like the first name and last name, etc then you use the json_encode php function.
Then you could do something like
PHP Code:
<?php
$user_data = array('firstname' => 'Joe', 'lastname' => 'Smith');
?>
<script type="text/javascript">
var user_data = <?php echo json_encode($user_data); ?>;
alert(user_data.firstname); //This creates a pop with the name Joe in it.
</script>
Bookmarks