作者LeoHsi (小呆)
看板PHP
标题[请益] 连动下拉选单取值(文字)
时间Sat Feb 23 01:59:58 2008
想要在下拉式选单取值
爬文爬网路参考许多范例
最基本的是这样:
HTML:
<select name="box" onchange="showInfo(this)">
<option value="0" text="台北市">台北市</option>
<option value="1" text="基隆市">基隆市</option>
<option value="2" text="台北县">台北县</option>
</select>
Js:
function showInfo(obj)
{
alert(obj[obj.selectedIndex].getAttribute("text"));
}
但是 因为我的选单是连动的 onchange的地方已经有一个函数
<select name=type size=1
onChange="Buildkey(this.options[this.options.selectedIndex].value);">
<option value=0>----请选择----</option>
<option value="1" >一一一</option>
<option value="2" >二二二</option>
function Buildkey(num) {
var ctr=1;
document.CodeForm.subtype.selectedIndex=0;
document.CodeForm.subtype.options[0]=new Option("----请选择----","");
if(num=="1") {
document.CodeForm.subtype.options[ctr]=new Option("你好");
ctr=ctr+1; }
if(num=="1") {
document.CodeForm.subtype.options[ctr]=new Option("哈罗");
ctr=ctr+1; }
document.CodeForm.subtype.length=ctr;
document.CodeForm.subtype.options[0].selected=true;
}
我想要把一一一取出来放到资料库里
请问要如何解决呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 210.192.215.120
1F:推 cleanwind:使用hidden栏位如何? 02/23 03:28
2F:→ LeoHsi:要怎麽使用呢? 02/23 09:21
3F:推 cleanwind:把某个栏位设成hidden,当他选到一一一去改变该栏位的值 02/23 12:22