小弟做Web不久,接手维护一个别人的Web工程,写新的小功能时候遇上问题.
有个类似如下的from:
<table>
<tr>
<input type="button" value="Test" onclick="Print('hahaform')"/>
</tr>
<tr>
<form id="hahaform" action="haha">
<input name="action" value="heihei" type="hidden"/>
</form>
</tr>
</table>
我要在按下按钮后在JS里面操作form的action属性,但是原来代码的结构,居然要在每个form里面添加一个名字叫做action的隐藏的控件,来提交一些消息,这个name是action的input我还不能删,但是我js就没办法取到form的action属性来操作了.请教各位大侠,是不是就没有办法了?不能用js来操作这个form的action属性了?
有个类似如下的from:
<table>
<tr>
<input type="button" value="Test" onclick="Print('hahaform')"/>
</tr>
<tr>
<form id="hahaform" action="haha">
<input name="action" value="heihei" type="hidden"/>
</form>
</tr>
</table>
我要在按下按钮后在JS里面操作form的action属性,但是原来代码的结构,居然要在每个form里面添加一个名字叫做action的隐藏的控件,来提交一些消息,这个name是action的input我还不能删,但是我js就没办法取到form的action属性来操作了.请教各位大侠,是不是就没有办法了?不能用js来操作这个form的action属性了?
解决方案 »
- 碰到个问题,做struts2的转换的时候,报这个错误
- 配置 Sping 2.0事务 报错了 no declaration can be found for element 'tx
- 在客户端做验证码的验证
- 页面打印问题
- Web开发 --八大优势能否助JSF统
- hibernate配置文件hbm.xml必须配主键么,不配置不行么?
- 跪求此代码运行不了的解决方案……
- 关于TOMCAT一闪而过
- js服务器怎么配置?
- 求助:org.springframework.web.servlet.PageNotFound noHandlerFound
- 求修改文本内容的jsp代码!
- 学JAVA的朋友进来啊~~要死人啦~~
document.hahaform.action="" 直接赋值
<form id="hahaform" name="hahaform" action="haha">
<head>
<script type="text/javascript">
function Print(formname)
{
var form = document.getElementById(formname);
alert(form.action);
}
</script>
</head><body>
<table>
<tr>
<input type="button" value="Test" onclick="Print('hahaform')"/>
</tr>
<tr>
<form id="hahaform" action="haha">
<input name="action" value="heihei" type="hidden"/>
</form>
</tr>
</table>
</body>
</html>
我就是想在按下按钮的时候显示from的action属性haha,而不是那个input的控件对象.
{
var form = document.getElementById("hahaform");
alert(form.action);
}
<form id="hahaform" action="haha" name="hahaform">
然后
function Print()
{
alert(document.hahaform.action);
}
你得方法还是不行哦,alert出来的还是那个input的action.另外,这个工程的框架不是我搭的,去掉那个名字叫做action的form的话,代码结构也要改动,还TMD是基类的,不晓得他还有多少页面要用到这个傻东西阿.55555,我也很委屈.回cs_zhanshen
你得和wenchao_222效果一样,都不行哦.呵呵我要的效果是打印出form的action属性,就是那个haha字符串.谢谢各位关注,我怀疑他这么设计了form以后,根本没办法在js里面获得form的这个action属性了,看来我得想别的办法了.贴子明天结,没有满意答案的话,就只把分送给你们二位了,谢谢.
alert(form.attributes('action').value);多谢!!!