下拉菜单啊写TEXT。。

shuixianzi00 2004-07-23 02:45:21
1 <select name="size" >
<?
$sql = "SELECT * FROM Tphotoprice where shop_id='$shopid' order by size ";
$result = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($result);
if($num > 0) {
while($row = mysql_fetch_array($result)) {
?>
<option value="<? echo $row['size'];?>"><? echo $row['size'];?></option><?}?>
</select>
2 <input name="price" type="text" value="">


要求是select选定一个值, price 里面就显示一个值,这个值是:
<?
$sql = "SELECT * FROM Tphotoprice where shop_id='$shopid' size='$选种的SIZE值' ";
$result = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($result);
if($num > 0) {
$row = mysql_fetch_array($result);
echo row['price'];
?>

并且这个TEXT里的值不能人为修改。谢谢,谢谢
...全文
105 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ice_berg16 2004-07-23
  • 打赏
  • 举报
回复
<select name="size" onchange="price.value=this.options[this.selectedIndex].price">
<?
$sql = "SELECT * FROM Tphotoprice where shop_id='$shopid' order by size ";
$result = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($result);
if($num > 0) {
while($row = mysql_fetch_array($result)) {
?>
<option value="<? echo $row['size'];?>" price="<?echo $row['price'];?>">
<? echo $row['size'];?>
</option>
<?}?>
</select>
<input name="price" type="text" id='price' readOnly>
shuixianzi00 2004-07-23
  • 打赏
  • 举报
回复
加上,有很多产品,size 和price是对应每一个商品
就是:产品1 size price;
产品2s ize price;
我不知道是不是有关系。
skystar008 2004-07-23
  • 打赏
  • 举报
回复
要用js的。
bflovesnow 2004-07-23
  • 打赏
  • 举报
回复
1 <select name="size" onchange="document.all.price.value=this.value">
<?
$sql = "SELECT * FROM Tphotoprice where shop_id='$shopid' order by size ";
$result = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($result);
if($num > 0) {
while($row = mysql_fetch_array($result)) {
?>
<option value="<? echo $row['size'];?>"><? echo $row['size'];?></option><?}?>
</select>
2 <input name="price" type="text" id="price" value="" readonly>
192168001001 2004-07-23
  • 打赏
  • 举报
回复
这个应该去JavaScript里去问

在size的onChange事件里把Price的值变一下就行了

21,882

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧