I want to get php booelan value with javascript. That is my code.
<script type="text/javascript">
var $j = jQuery.noConflict();
var isValue = $j(<?php isset($getResult[]); ?>);
alert(isValue);
</script>
You'll have to convert the boolean result of isset() into a string representation of 'true' or 'false' so that it can be understood by the javascript parser. Like this:
var isValue = $j(<?php isset($getResult[]) ? echo 'true' : echo 'false'; ?>);
It should be like this
<script type="text/javascript">
var $j = jQuery.noConflict();
var isValue = $j(<?php if (isset($getResult)){ echo true;} else {echo false;} ?>);
alert(isValue);
</script>
You cannot use $getResult[] for reading using issest. It will return fatal error or you have to specify some index in the array.
If you want to check if it is an array then you can use :
<script type="text/javascript">
var $j = jQuery.noConflict();
var isValue = $j(<?php if (isset($getResult) && is_array($getResult)){ echo true;} else {echo false;} ?>);
alert(isValue);
</script>
<script> var isValue = <?php echo isset($getResult) ? 'true' : 'false'; ?> </script>
echoit?echo variable ? "true" : "false"?