怎么获得form里的所有值呀

9 views
Skip to first unread message

yefeng

unread,
Apr 15, 2009, 9:38:49 PM4/15/09
to 中国Ajax论坛
我是用html+js+asp做的,首先我建了一个表单,里面有好几个值,在我点击时想把表单的几个值如:uid、pwd同时提交给js,再由js传给
asp处理数据库,请问要怎么样才可以让js收到form的所有值呀?我是新手,刚学,大哥帮帮忙了

张沈鹏

unread,
Apr 16, 2009, 10:52:16 AM4/16/09
to Aja...@googlegroups.com
jquery 有个
function showValues() {
var str = $("form").serialize();
$("#results").text(str);
}

$(":checkbox, :radio").click(showValues);
$("select").change(showValues);
showValues();
http://docs.jquery.com/Ajax/serialize

Alex Cheng

unread,
May 14, 2009, 5:56:29 AM5/14/09
to 中国Ajax论坛
如果你使用Ajax框架就简单了,比如用dojo的formToObject。如果是自己用JavaScript的话,用
getElementsByTagName得到input元素再取值。不过看起来你的表单的元素是确定的话,就挨个取就好了。
Reply all
Reply to author
Forward
0 new messages