假设我数据库里有三个字段ys(颜色),zdz(最低值),zgz(最高值);ys字段里有四个值01,02,03,04.现在我想让每一个颜色值对应一个最低值和最高值即01对应[10,20],02对应[20,30]以此类对,请问这个js怎么写,来控制text框里的值需在对应的区间内?------------颜色字段是个下拉框,,,,,,,

解决方案 »

  1.   

    <script type="text/javascript">
    function ss(){
    var se=document.getElementById("test");
    var a=se[se.selectedIndex].value;
    document.getElementById("test2").value=a;
    }
    </script>
    </head><body>
    <select id="test" onchange="ss()">
    <option value="[10-20]">01</option>
    <option value="[20-30]">02</option>
    <option value="[30-40]">03</option>
    <option value="[40-50]">04</option>
    </select>
    <input type="text" id="test2">
    </body>
    完全不明白你的意思
      

  2.   

    <table id=tableId border="0" cellspacing="1" cellpadding="0"
    align="center" width="95%">
    <tr>
    <td>
    <fieldset style="width: 98%">
    <table width="100%" class="grid2">
    <tr height="25">
    <td class="title" width="130">颜色类型&nbsp;<font
    color="#ff0000">*</font>&nbsp;</td>
    <td class="content" width="280">
    <select name="yslxbh" id="yslxbh" style="width: 240px;" >
    <%=ysLogic.getYslxbhOption(yslxbh)   %>
    </select>
    </td>
    </tr>
    </table>
    <table width="100%" class="grid2">
    <tr height="25">
    <td class="title" width="130">最低值&nbsp;<font
    color="#ff0000">*</font>&nbsp;</td>
    <td class="content" width="280">
    <input type="text" name="zdfz" id="zdfz" value="<%=zdz %>" style="width: 240px;" onblur="checkNumber()" />
    </td>
    </tr>
    </table>
    <table width="100%" class="grid2">
    <tr height="25">
    <td class="title" width="130">最高值&nbsp;<font
    color="#ff0000">*</font>&nbsp;</td>
    <td class="content" width="280">
    <input type="text" name="zgfz" id="zgfz" value="<%=zgz %>" style="width: 240px;" onblur="checkNumber()" />
    </td>
    </tr>
    </table>
    </fieldset></td>
    </tr>
    </table>
      

  3.   

    <script type="text/javascript">
    function ss(){
    var se=document.getElementById("test");
    var a=se[se.selectedIndex].value;
    a=a.split('-')
    document.getElementById("test2").value=a[0];
    document.getElementById("test3").value=a[1];
    }
    </script>
    </head><body>
    <select id="test" onchange="ss()">
    <option value="10-20">01</option>
    <option value="20-30">02</option>
    <option value="30-40">03</option>
    <option value="40-50">04</option>
    </select><br/>
    最低<input type="text" id="test2"><br/>
    最高<input type="text" id="test3">
    这样??