sub1 is not working it is being called on the click of the button can use please help me how can i get values from php variables to javascript variable,
<html>
<head>
<script language="javascript">
function sub1()
{
var x=<?php echo $present; ?>;
var y=<?php echo $min; ?>;
var z=<?php echo $max; ?>;
change(x,y,z);
alert("hello");
change();
}
function change(var no,var min,var max)
{
alert("hello1");
var x=document.getElementById("show");
x.src='<?php
if($con==true)
{
$cmd="select * from showcase where item_no=3";
if($res=$con->query($cmd))
{
if($res->num_rows>0)
{
while($rw=$res->fetch_array())
{
echo "$rw[1]";
}
}
else
{
echo "no record found";
}
}
else
{
echo "query problem";
}
}
?>';
}
</script>
</head>
</html>
i am working on a slider which changes pic on the click of the button
var x="<?php echo $present; ?>";var x = <?php echo json_encode($present); ?>;. Not wrapping it in quotes.true" and "a string that does not contain special characters such as newlines or double quotes". As I see it, it's easier to usejson_encodeall the time instead of thinking "do I echo this or encode it first?".