< a href>而不是<输入提交>按键 [英] <a href> instead of <input submit> button
问题描述
< input class =submittype =submitclass =输入value =Addname =command/>
但现在我想使用< a href>
代替。问题是, value =Add
是非常重要的。
c $ c $< a href> 就像这样。
< a href =javascript :document.register.submit();>提交< / A>
有什么建议吗?问题是,该网站并未发现此特定的< a href>
被点击了,因此无法运行我的php代码。
首先我强烈推荐jquery。它使用JavaScript处理不同的世界,并简化了一些问题,特别是跨越不同的浏览器。
我建议您创建一个隐藏输入来设置值与。
< script type =text / javascript>
函数submitFormWithValue(val){
document.getElementById('command')。value = val;
document.forms [test]。submit();
}
< / script>
< input type =hiddenname =commandvalue =/>
< / form>
< a href =javascript:submitFormWithValue('foo')>提交< / a>
我没有测试我的代码,但它应该足够接近以查看它的工作原理。再次检查jquery,它会使处理javascript变得更容易!
I originally had a submit button.
<input class="submit" type="submit" class="input" value="Add" name="command" />
but now I would like to use a <a href>
instead. The issue is, the value="Add"
is very important.
I'm currently making the <a href>
like this.
<a href="javascript:document.register.submit();">submit</a>
Any suggestions? Issue is, the site is not picking up that this specific <a href>
was clicked, and therefore won't run my php code.
First off I highly recommend jquery. It makes a world of difference when working with javascript and simplifies a number of issues especially cross different browsers.
What I suggest is that you create a hidden input to set the value with.
<script type="text/javascript">
function submitFormWithValue(val){
document.getElementById('command').value = val;
document.forms["test"].submit();
}
</script>
<form id="test" name="test" action="#" method="post">
<input type="hidden" name="command" value="" />
</form>
<a href="javascript:submitFormWithValue('foo')">Submit</a>
I didn't test my code but it should be close enough to see how it works. Again check out jquery it will make dealing with javascript a lot easier!
这篇关于< a href>而不是<输入提交>按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!