求一个js获取文本框值的写法--急,在线等,提供帮助即给分

vgy12304 2010-01-08 09:40:05
要js实现一个,点击下面按钮,把获得的文本框和复选框的值,插入到上面的表单中,提交
<script type='text/javascript'>
function clickSet()
{
var actiontype=document.all('actiontype').value/document.getElementsByName('actiontype').value;;
alert(actiontype); ///---->两种写法都不行,执行时,这里提示 undefinded
search_form.actiontype.value=actiontype.value;
search_form.actionid.value=document.getElementsByName('nid[]').value;
search_form.submit();
return false;
}
</script>

<form name='search_form'>
...
</from>

下面内容,不能放到上面的from中,跟别的js发生冲突

<input type=checkbox name="nid[]" value=4>
<input type=checkbox name="nid[]" value=5>
<input type=checkbox name="nid[]" value=6>

<input type=checkbox id=chkall onclick='checkall()'>全选</td>
<input type=radio name=actiontype value=multdel>删除
input type='submit' class='btn2' name=submit value=提交 onclick='clickSet();'>
...全文
196 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingfly1818 2010-01-08
  • 打赏
  • 举报
回复

<head>
<title>test</title>
<script type="text/javascript">
function clickSet() {
var form = document.forms[0];
var actiontype = form.actiontype.value;
alert(actiontype);
return false;
}

</script>
<form>
</head>
<body>

<input type=checkbox name="nid[]" value=4>
<input type=checkbox name="nid[]" value=5>
<input type=checkbox name="nid[]" value=6>

<input type=checkbox id=chkall onclick='checkall()'>全选 </td>
<input type="radio" name="actiontype" value="multdel">删除
<input type='button' class='btn2' name=submit value=提交 onclick='clickSet();'>
</form>
</body>
</html>
vgy12304 2010-01-08
  • 打赏
  • 举报
回复
笨是笨了点,谢谢楼上各位的帮忙,给分结贴
vgy12304 2010-01-08
  • 打赏
  • 举报
回复
不对啊,老兄

我换思路了,把下面的部分也用<form name=upfrom>..</form>套起来,复制上面表单<form name='search_form'>的所有数据,下面表单<form name=upfrom>,再做一次提交
sports98 2010-01-08
  • 打赏
  • 举报
回复
<input id=xxxx
vgy12304 2010-01-08
  • 打赏
  • 举报
回复
var actionid; ???

sports98 2010-01-08
  • 打赏
  • 举报
回复
你就没定义ID当然没了。定义ID
vgy12304 2010-01-08
  • 打赏
  • 举报
回复
document.getElementById('actionid').value

这个不行,获取不到,提示undefinded
阿_布 2010-01-08
  • 打赏
  • 举报
回复
document.getElementById("id");
sports98 2010-01-08
  • 打赏
  • 举报
回复
哈,接点分。N年没混论坛了现在缺分哈~


//提取出所有input标签内容

//Tips: document.getEle.... 你可以修改为你指定容器,例如 document.getElementById('getInputArea')
//getInputArea -> <div id="getInputArea">...这里有你想要提取的input</input>
var inputs = document.getElementByTagName("input");
var getValue = "";
for(int i=0;i<inputs.length;i++)
{
if(inputs[i].type=="checkbox" && inputs[i].checked)
{
getValue = inputs[i].value+",";
}
}
document.getElementById('actionid').value = getValue.replace(",$","");

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧