sub1 不起作用,单击按钮即可调用它可以使用请帮助我如何将值从 php 变量获取到 javascript 变量,
<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>
我正在研究一个滑块,它在单击按钮时更改图片