【求助】如何通过javascript更改隐藏hidden的值? 想通过一个redio的选定事件对一个hidden赋值,相关语法怎么弄呢?是用onselect事件呢还是用spry:select事件呢?不用中文为啥不管用哪个事件提交后浏览器的地址栏也有一堆乱码呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <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> 这个意思?<!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> 楼上的两位的代码我试过了,是好使的,不过那个onselect方法时干什么的呢?貌似那个不好使! onselect 事件会在文本框中的文本被选中时发生。http://www.w3school.com.cn/htmldom/event_onselect.asp 如果是赋给HIDDEN,没必要设置onclick事件并对每个点击事件做反应,只需要在提交表单的事件中作一次处理就可以了。 看看这段代码哪错了? javascript 正则表达式 js怎样补全位数? 我这样转换字符串 为什么出错了? 没有匹配正确??? 会服务器端javascrpit代码的高手请来帮帮忙!! 如何关闭父级的iframe窗口呢? [Help]switch如何嵌套switch 请问,怎样让弹出式页面目录上的链接关闭本页的同时,在上一级页面上显示新网页内容? asc码值 html页面table数据传递问题(详细见图和说明) 菜鸟入门问题:为什么我这样写会没有反应呢 使用jquery easyui的dialog的一个诡异的问题!! 求教
<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>
<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>