如果涉及到数据库,在下拉选单选中不同值时,文本框的值对应到其他字段值??

ahking 2002-04-26 10:23:36
如果有一个数据库含有名称、单价、数量字段,当Select选择名称时,一个文本框显示单价、一个显示数量,怎么写??
...全文
46 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2002-04-26
  • 打赏
  • 举报
回复
<form>
<select onchange="this.form.quantity=this.options[this.selectedIndex].getAttribute('quantity');this.form.price=this.options[this.selectedIndex].getAttribute('price'); ">
<option quantity="数量" price="单价">名称</option>
</select>
<input name="quantity">
<input name="price">
</form>
ahking 2002-04-26
  • 打赏
  • 举报
回复
纠正一下:

<form>
<select onchange="this.form.quantity.value=this.options[this.selectedIndex].getAttribute('quantity');this.form.price.value=this.options[this.selectedIndex].getAttribute('price'); ">
<option quantity="数量" price="单价">名称</option>
</select>
<input name="quantity">
<input name="price">
</form>

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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