<code>
<title>All Items</title>
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
>
<center>
<font color=
"white"
>所有文具</font>
<br><br><br>
<hr>
<br><br><br>
</center>
<table width=
"370"
border=
"1"
>
<tr>
<td><img src=
"/static/imghw/default1.png"
data-src=
"1.jpg"
class
=
"lazy"
style=
"max-width:90%"
style=
"max-width:90%"
alt=
"javascript - 如何把php取出来的值放入js函数中?"
></td>
<td>
<font color=
"white"
>品名:笔记本<br>
价格:10元<br>
描述:A4大小,120页<br>
库存:<script language=
"php"
>
mysql_connect(
"localhost"
,
"root"
,
""
)
or
die
(mysql_error());
mysql_select_db(
"user_info"
);
$sql
=
"select * from inventory where pid='1'"
;
$query
=mysql_query(
$sql
);
$result
= mysql_fetch_array(
$query
);
@
$num
=
$result
[
'pnum'
];
echo
$num
;
</script><br>
购买数量:<input type=
"text"
size=
"5"
id=
"num"
><br>
</font><center>
<br>
<input type=
"button"
value=
"加入购物车"
onclick=
"javascript:test('<?php echo $num?>')"
>
</center>
</td>
</tr>
<tr>
<td><img src=
"/static/imghw/default1.png"
data-src=
"2.jpg"
class
=
"lazy"
style=
"max-width:90%"
style=
"max-width:90%"
alt=
"javascript - 如何把php取出来的值放入js函数中?"
></td>
<td> </td>
</tr>
<tr>
<td><img src=
"/static/imghw/default1.png"
data-src=
"3.jpg"
class
=
"lazy"
style=
"max-width:90%"
style=
"max-width:90%"
alt=
"javascript - 如何把php取出来的值放入js函数中?"
></td>
<td> </td>
</tr>
<tr>
<td><img src=
"/static/imghw/default1.png"
data-src=
"4.jpg"
class
=
"lazy"
style=
"max-width:90%"
style=
"max-width:90%"
alt=
"javascript - 如何把php取出来的值放入js函数中?"
></td>
<td> </td>
</tr>
</table>
<script type=
"text/javascript"
>
function
Check1(){
var
input = document.getElementById(
"num"
);
if
(input.value)
}
</script>
</code>