想通过一个redio的选定事件对一个hidden赋值,相关语法怎么弄呢?
是用onselect事件呢还是用spry:select事件呢?不用中文为啥不管用哪个事件提交后浏览器的地址栏也有一堆乱码呢?

解决方案 »

  1.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
    *{margin:0; padding:0;}
    </style>
    </head>
    <body>
    <input type="radio" value="" id="ra" name="a" />赋值
        <input type="hidden" id="hid" />
        <script>
         document.getElementById('ra').onclick = function(){
    if(this.checked){
    document.getElementById('hid').value = '我是被赋值过的';
    }
    alert(document.getElementById('hid').value);
    };

        </script>
    </body>
    </html>
      

  2.   

    这个意思?<!doctype html>
    <html>
    <head>
    <meta charset="gb2312" />
    <style>
    </style> </head>
    <body>
    <input type="radio" name="r" value="1" checked="checked" />1
    <input type="radio" name="r" value="2" />2
    <input type="radio" name="r" value="3" />3
    <input type="text" id="test" value="1" />
    <script>
    function $(o){return document.getElementById(o)}

    var obj = document.getElementsByName('r');

    for(var i = 0; i < obj.length; i++){
    obj[i].onclick = function(){
    $('test').value = this.value
    }
    }




    </script>
    </body>
    </html>
      

  3.   

    楼上的两位的代码我试过了,是好使的,不过那个onselect方法时干什么的呢?貌似那个不好使!
      

  4.   

    onselect 事件会在文本框中的文本被选中时发生。http://www.w3school.com.cn/htmldom/event_onselect.asp
      

  5.   

    如果是赋给HIDDEN,没必要设置onclick事件并对每个点击事件做反应,只需要在提交表单的事件中作一次处理就可以了。