你试下把value里的值改为100,90,80

解决方案 »

  1.   


    可以偷懒不?<html>
    <head>
    <title> new document </title>
    <script language="javascript">
    </script>
    </head>
    <body>
    <select name="sel" width="100" onchange="document.getElementById('price').innerText=this.value">
    <option></option>
    <option value="80">B</option>
    <option value="90">S</option>
    <option value="100">M</option>
    </select>
    <span id="price"></span>
    </body>
    </html>
      

  2.   

    <select       name="select1" onchange=func(this)>
    <option       value="a">   a   </option>
    <option       value="b">   b   </option>
    <option       value="c">   c   </option>
    </select> 
    <>
    <script   language=javascript>
    var str1 = 'abcdefgh', str2 = 'abcdefgh';
    var obj1 = new String('abcdefgh'), obj2 = new String('abcdefgh');document.writeln([str1==str2, str1===str2], '<br>');
    document.writeln([obj1==obj2, obj1===obj2]);
    function func(a){
      if(a.value=="a"){
         document.getELementById("textId").value="100"
      }
      if(a.value=="b"){
         document.getELementById("textId").value="90"
      }
      if(a.value=="c"){
         document.getELementById("textId").value="80"
      }
    }
    </script>
      

  3.   

    谢谢你们啊。
    andy1217、s_liangchao1s,不行啊,因为下拉菜单和text内两个值得我都要传送。
    mingxuan3000,谢谢您。var   str1   =   'abcdefgh',   str2   =   'abcdefgh';
    var   obj1   =   new   String('abcdefgh'),   obj2   =   new   String('abcdefgh');document.writeln([str1==str2,   str1===str2],   ' <br> ');
    document.writeln([obj1==obj2,   obj1===obj2]); 这是什么意思来的?
      

  4.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
       <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
         <script language="JavaScript">
          function changeValue() {
    var value = document.getElementById("selId").value;
    alert(value);
    if ("大" == value) {
    document.getElementById("outDate").value = 100;
    } else if("中" == value) {
    document.getElementById("outDate").value = 90;
    } else if("小" == value) {
    document.getElementById("outDate").value = 80;
    }
    }
          </script>
       </head>
       <body>
     
    <select id="selId" onchange="changeValue()">
    <option value="大" >大</option>
    <option value="中" >中</option>
    <option value="小" >小</option>
    </select>
      <input type="text" id="outDate" /><br/>
        <input type="submit" />        </body>
    </html>
      

  5.   

    喔,谢谢。
    我这样子写,怎么执行不了?
    <form>
    <select               name="select1"   onchange=func(this)>
    <option               value="a">       a       </option>
    <option               value="b">       b       </option>
    <option               value="c">       c       </option>
    </select>  <input type="text" name="textId">
    </form><script   language=javascript>
    function   func(a){
        if(a.value=="a"){
              document.getELementById("textId").value="100"
        }
        if(a.value=="b"){
              document.getELementById("textId").value="90"
        }
        if(a.value=="c"){
              document.getELementById("textId").value="80"
        }
    }
    </script>还有,第一次载入页面时就要用一个默认已经选好的下拉选项、以及价格。
    如(“大”,然后价格“100")
      

  6.   


    <html>
    <head>
    <title> new document </title>
    <script language="javascript">
    function Change(obj){
    var obs=document.getElementById('price');
    var oValue=obj.options[obj.selectedIndex].text;
    switch(oValue){
    case "B":
    obs.innerText="100";
    break;
    case "S":
    obs.innerText="80";
    break;
    case "M":
    obs.innerText="90";
    break;
    }
    }</script>
    </head>
    <body>
    <select name="sel" id="sel" width="100" onchange="Change(this)">
    <option></option>
    <option value="B">B</option>
    <option value="S">S</option>
    <option value="M">M</option>
    </select>
    <span id="price"></span>
    </body>
    </html>----------------------------写个不偷懒的--------------------------------------
      

  7.   

    sinpotyuu,谢谢您,您的代码一执行就有提示错误了。
      

  8.   

    其实上面写的所有的都是偷懒的 都是按你的value写的阿 我最后写的这个可以
      

  9.   

    onchange只有onchange才执行,
    第一次载入页面时就要用一个默认已经选好的下拉选项、以及价格。onload的 时候要,写在onload里面另document.getELementById要用Id,你的text只有name,没id
      

  10.   

    document.getElementById //上面写错了,注意大小写
      

  11.   

    mingxuan3000,谢谢您,这个也要分大小写的。
    s_liangchao1s,谢谢您。
    您的代码执行OK。不过,当第一次载入时我想默认有一个<option value="B">B</option>,并且对应的价格显示:100。
    这要怎么改的。对了,还有<span id="price"></span>这样子来传递,我在另外一个页面接收可以接收的吗?
      

  12.   

    mingxuan3000,谢谢您,这个也要分大小写的。
    s_liangchao1s,谢谢您。
    您的代码执行OK。不过,当第一次载入时我想默认有一个<option value="B">B</option>,并且对应的价格显示:100。
    这要怎么改的。对了,还有<span id="price"></span>这样子来传递,我在另外一个页面接收可以接收的吗?
      

  13.   


    <html>
    <head>
    <title> new document </title>
    <script language="javascript">
    function Change(obj){
    var obs=document.getElementById('price');
    var oValue=obj.options[obj.selectedIndex].text;
    switch(oValue){
    case "B":
    obs.innerText="100";
    break;
    case "S":
    obs.innerText="80";
    break;
    case "M":
    obs.innerText="90";
    break;
    }
    }
    function sel(){
    document.getElementById('sel').value="B";
    document.getElementById('price').innerText="100";
    }
    </script>
    </head>
    <body onload="sel()">
    <select name="sel" id="sel" width="100" onchange="Change(this)">
    <option></option>
    <option value="B">B</option>
    <option value="S">S</option>
    <option value="M">M</option>
    </select>
    <span id="price"></span>
    </body>
    </html>可以接收 楼主是JAVA?
      

  14.   

    帅帅宝宝的作品必然全部代码,绝对满足你的要求(只支持IE),请给分:
    <HTML> 
     <HEAD> 
     </HEAD> 
     <BODY> 
     <select   name="select1" onchange="a()"> 
    <option>大</option> 
    <option>小</option> 
    <option>中</option> 
    </select> 
    <SPAN   id="price1" style="display:none;">100</SPAN> 
    <SPAN   id="price2" style="display:none;">90</SPAN> 
    <SPAN   id="price3" style="display:none;">80</SPAN> 
    <script language="JavaScript"> 
    function a(){
        var x = select1;
        for (i=0;i<x.length;i++){
        if(x.options[i].selected){
                switch(x.options[i].innerText){
                    case "大":
                    price1.style.display="block";
    price2.style.display="none";
    price3.style.display="none";
                        break;
                    case "小":
                    price2.style.display="block";
    price1.style.display="none";
    price3.style.display="none";
                        break;
                    case "中":
                    price3.style.display="block";
    price1.style.display="none";
    price2.style.display="none";
                        break;
                }
    }
        }  
    }
    </script> 
     </BODY> 
    </HTML> 
      

  15.   

    s_liangchao1s,再次谢谢您。
    不敢再麻烦您了,最后一问,您的代码要怎么才可以支持firefox,
    在firefox下运行不了。iori_wen,谢谢您,我差点忘了要支持firefox才行的。
      

  16.   

    很简单,使用getElementById,就可以支持FireFox
      

  17.   

    document.getElementById('price');
    上面不是也用了吗?
      

  18.   

    如var x = select1写成x = getElementById("select1")
      price1写成 getElementById("price1")
    就可以了
      

  19.   

    iori_wen,哈哈,发觉您挺有个性的嘛。
    对了,我发觉得您的代码比s_liangchao1s的要长啊,如果我用s_liangchao1s的代码,
    要怎么改才会支持FF的。
    var obs=document.getElementById('price');
    是用到了getElementById的啊,但是在FF下就是不能执行。
      

  20.   

    为什么我比他代码长?你觉的呢?
    你没看到我的大部分代码都是控制span的吗?而他的代码是取巧,不符合你的要求。
      

  21.   

    iori_wen,如果我在另外一个页面要接收这些传送过来的值,
    一般我就要接收一个price就行了,但是如果换成您上面写的,
    是不是要接收后再判断有几个price的ID,再来获取值。
      

  22.   

    [code]
    <html>
    <head>
    <title> new document </title>
    <script language="javascript">
    function Change(obj){
    var obs=document.getElementById("price").firstChild;
    var oValue=obj.options[obj.selectedIndex].text;
    switch(oValue){
    case "B":
    obs.data="100";
    break;
    case "S":
    obs.data="80";
    break;
    case "M":
    obs.data="90";
    break;
    }
    }
    function sel(){
    document.getElementById('sel').value="B";
    document.getElementById('price').innerText="100";
    }
    </script>
    </head>
    <body onload="sel()">
    <select name="sel" id="sel" width="100" onchange="Change(this)">
    <option value="B">B</option>
    <option value="S">S</option>
    <option value="M">M</option>
    </select>
    <span id="price">100</span>
    </body>
    </html>
    [/code]
    这样没问题了吧
      

  23.   

    [html]
    <html>
    <head>
    <title> new document </title>
    <script language="javascript">
    function Change(obj){
    var obs=document.getElementById("price").firstChild;
    var oValue=obj.options[obj.selectedIndex].text;
    switch(oValue){
    case "B":
    obs.data="100";
    break;
    case "S":
    obs.data="80";
    break;
    case "M":
    obs.data="90";
    break;
    }
    }
    function sel(){
    document.getElementById('sel').value="B";
    document.getElementById('price').innerText="100";
    }
    </script>
    </head>
    <body onload="sel()">
    <select name="sel" id="sel" width="100" onchange="Change(this)">
    <option value="B">B</option>
    <option value="S">S</option>
    <option value="M">M</option>
    </select>
    <span id="price">100</span>
    </body>
    </html>
    [/html]
      

  24.   

    靠,到现在还没结贴,鄙视你!
    算了,给你个极品代码,全浏览器都支持!帅帅的宝宝必定全部代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>无标题页</title>
    </head>
    <body>
     <select id="select1"> 
    <option value="B">大</option> 
    <option value="S">小</option> 
    <option value="M">中</option> 
    </select> 
    <span id="span1"></span>
    <script language="javascript" type="text/javascript">
    var objselect1 = document.getElementById("select1");
    var objspan1 = document.getElementById("span1");
    objselect1.onchange = function(){
                     switch(objselect1.options[objselect1.selectedIndex].value){
         case "B" :
             if(objspan1.hasChildNodes()){
             objspan1.removeChild(objspan1.firstChild);
         }
         objspan1.appendChild(document.createTextNode("100"));
     break;
         case "S" :
             if(objspan1.hasChildNodes()){
             objspan1.removeChild(objspan1.firstChild);
         }
         objspan1.appendChild(document.createTextNode("90"));
     break;
                         case "M" :
             if(objspan1.hasChildNodes()){
             objspan1.removeChild(objspan1.firstChild);
         }
         objspan1.appendChild(document.createTextNode("80"));
     break;
     }
                 }
    </script>
    </body>
    </html>
      

  25.   

    再缩短下代码:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>DOM标准</title>
    </head>
    <body>
     <select id="select1"> 
    <option value="B">大</option> 
    <option value="S">小</option> 
    <option value="M">中</option> 
    </select> 
    <span id="span1"></span>
    <script language="javascript" type="text/javascript">
    var objselect1 = document.getElementById("select1");
    var objspan1 = document.getElementById("span1");
    function removenode(){if(objspan1.hasChildNodes()){objspan1.removeChild(objspan1.firstChild);}}
    objselect1.onchange = function(){
                     switch(objselect1.options[objselect1.selectedIndex].value){
         case "B" :
             removenode()
         objspan1.appendChild(document.createTextNode("100"));
     break;
         case "S" :
             removenode()
         objspan1.appendChild(document.createTextNode("90"));
     break;
                         case "M" :
             removenode()
         objspan1.appendChild(document.createTextNode("80"));
     break;
     }
                 }
    </script>
    </body>
    </html>
      

  26.   

    帅帅的宝宝,谢谢你,不用急的,我今天才上班啊。
    Lion5859,谢谢你。
    好了,结贴先了,谢谢各位了。。