javascript怎么提交表单元素?

<input type="text" name="a" id="a" />
<input type="radio" name="b" value="radiobutton" id="b"/>
<input type="button" name="Submit" value="按钮" onclick="window.location.href='a.php'" />
javascript怎么能把id=a和ia=b的值,传给a.php呢,望解答

<script>
function setValues(){
var aValue=document.getElementById("a").value;
var bValue=document.getElementById("b").value;
window.location.href='a.php?a='+aValue+'&b='+bValue;
}
</script>

<input type="button" name="Submit" value="按钮" onclick="javascript:setValues();" />
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-03-01
外面套用一个form 调用form的submit事件 action就是你的目的地址了

<form action="a.php">
<input type="text" name="a" id="a" />
<input type="radio" name="b" value="radiobutton" id="b"/>
<input type="Submit" name="Submit" value="按钮" />
</form>

a.php用request对象获取啦..

具体的需要在仔细的百度一下了
第2个回答  2010-03-01
<input type="text" name="a" id="a" />
<input type="radio" name="b" value="radiobutton" id="b"/>
<input type="button" name="Submit" value="按钮" onclick="linka()" />

<script language="javascript">
var str="a.php?";
var a=document.getElementById("a").value;
var b=document.getElementById("b").value;
var str=str+"a="+a+"&b="+b;
window.location.href=str;
</script>
第3个回答  2010-03-02
window.location.href='b.php?a='+document.getElementByID('a').value+'&b='+document.getElementByID('b').value;
当然这样只能get方式提交,要post还是放进form里边吧
第4个回答  2010-03-02
1.js获取,用document.getElementById().value,然后用按钮做链接,用url传递。在a.php来获取。
2.建议还是用form括起来。然后按钮触发一个函数,里面用:document.forms[0].action = "../a.php";
document.forms[0].submit();
第5个回答  2010-03-02
一种是写进cookice中,php去读取。
一种是使用post提交表单
一种是使用get附加到Url中
-------------------------------
这三种的话,可以使用javascript去写入cookice,另外两种,完全可以不使用javascript。

PS. 表单元素一定套在form标签里,否则它是不会传递出去的。