使用JS動態設定select的預設值
阿新 • • 發佈:2019-02-19
<script language="javascript">
<!--
function UpOption(obj,value){
for(var i=0;i<3;i++){
var newObj=document.createElement('OPTION');
if(i==0)
{
newObj.text="不變";
}
elseif (i==1)
{
newObj.text="上升";
}
elseif (i==2)
{
newObj.text="下降";
}
newObj.value=i;
obj.add(newObj);
}
obj.value=value;
}
//-->
</script>
<body>
<form name="rxform7612">
<select name="current" style="width:100px;">
</select>
<script language="JavaScript" type="text/JavaScript">
UpOption(document.rxform7612.current,0);
</script>
</form>
<!--
function UpOption(obj,value){
for(var i=0;i<3;i++){
var newObj=document.createElement('OPTION');
if(i==0)
{
newObj.text="不變";
}
elseif (i==1)
{
newObj.text="上升";
}
elseif (i==2)
{
newObj.text="下降";
}
newObj.value=i;
obj.add(newObj);
obj.value=value;
}
//-->
</script>
<body>
<form name="rxform7612">
<select name="current" style="width:100px;">
</select>
<script language="JavaScript" type="text/JavaScript">
UpOption(document.rxform7612.current,0);
</script>
</form>