由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Newbie javascript question: change radio button updates textbox message
相关主题
Q: 2 submit buttons in 1 page (转载)PHP/JSP/ASP等页面语言应该被慢慢抛弃了吧?
Angular ng-include not workingreplace document body,but js does not run
Angularjs ng-click redirect not working as expectedHow to get button name? (转载)
wpf:命令和点击(onclick)如何用tornado web server写可以处理curl命令的程序
bootstrap centering input field太它奶奶的复杂了Javascript: dynamicly enable draggable id?
GWT radio button 的Style的问题感觉vert.x上的callback hell比node上还要更丑陋
get_innerHTML需要什么样的permission?VISUAL STUDIO 2005 输出窗口(output) 怎么找不到?
innerHtml的问题继承的assignment operator问题
相关话题的讨论汇总
话题: radio话题: choice话题: message话题: input话题: button
进入Programming版参与讨论
1 (共1页)
w*s
发帖数: 7227
1
hi i'm new to these.
so i have 2 radio buttons, "choice 1", "choice 2".
when i choose 1st, i want to see text box message saying "you choosed 1".
same for the 2nd radio.
Any sample pls !
Thanks !
w****w
发帖数: 521
l**********n
发帖数: 8443
3





Radio buttons


Choice 1
Choice 2


Message:


d****i
发帖数: 4809
4
最后那个JS应该是
$(function(){
$(":radio").click(function(e) {
var message1 = e.target.name;
var message2 = message1.concat(' ' + e.target.value);
alert(message2);
});
})
否则出来的没有选项号

【在 l**********n 的大作中提到】
:
:
:
:
:
: Radio buttons
:
:
: Choice 1
: Choice 2

w*s
发帖数: 7227
5
谢谢各位高手!

【在 w****w 的大作中提到】
: http://jsbin.com/xeyak/1/edit?html,js,output
w*s
发帖数: 7227
6
Why it's not working for me, any suggestions appreciated.
js1.js----------------------------------
function button_click()
{
document.querySelector("#msg').innerHTML = 'You chosed' + document.
querySelector('input[name="choice"]:checked').value + '.';
}
my.html----------------------------------------




Raido