
<form name="form1">
a:<input type="text" name="a"><BR><BR>
b:<input type="radio" name="b" value="中国">中国<BR><BR>
c:<input type="checkbox" name="c"><BR><BR>
d:<input type="checkbox" name="d"><BR><BR>
e:<input type="button" name="e" value="我是button"><BR><BR>
<input type="button" name="f" value="点击我获取type" onclick="showtype();">
<input type="button" name="ff" value="点击我获取checkbox数量" onclick="shownum();">
<input type="button" name="ff" value="点击我获取radio的值" onclick="showvalue();">
</form>
<script>
function showtype(){
g=documentgetElementsByTagName("input");
for(i=0;i<glength;i++){
alert(g[i]name+"的type是:"+g[i]type);
}
}
function shownum(){
h=documentgetElementsByTagName("input");
hh=0;
for(j=0;j<hlength;j++){
if(h[j]type=="checkbox"){hh=hh+1;}
}
alert("checkbox的个数是:"+hh);
}
function showvalue(){
k=documentgetElementsByTagName("input");
for(l=0;l<klength;l++){
if(k[l]type=="radio"){alert("radio的值是:"+k[l]value);}
}
}
</script>
有两种情况:
第一种:这个button是个 <input type="button" id="button" value="button"/> 元素的话那么获取这个button的值就是
var buttonValue= documentgetElementById('button')value;
第二种:这个button是个 <button id="button" > button </button>元素的话那么获取这个button的值就是
var buttonValue= documentgetElementById('button')innerHTML;
或者:
var buttonValue= documentgetElementById('button')innerText;这个也行
赞同二楼的第一种写法:而第二种应该这样写:(不然会报空)
=========================================
<input type="button" id="but" value="点击">
documentgetElementById('but')onclick=function()
{
alert("你点击了button按键:"+thisvalue)
}
==================================
还可以这样写;
===================================
function but()
{
alert("你点击了button按键:"+documentgetElementById('but'))
}
<input type="button" id="but" value="点击" onclick="but()">
<from name="from" action="提交到的地址" >
<input type="radio" name="radio" value="值">
<input type="image" src="按钮的">
</from>
制作一个表单,提交到处理的asp页面
radio=requestfrom("radio")
在asp处理也通过上面获取name为radio的单选框的value值,然后进行相应的处理就行了。
以上就是关于input框type的值是button如何获取用户点击的值全部的内容,包括:input框type的值是button如何获取用户点击的值、如何获取button上的文字、javascript 中怎么取button的返回值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)