提交不在javascript中工作
检查这是否有帮助提交不在javascript中工作,javascript,html,Javascript,Html,检查这是否有帮助 document.getElementsByName('frm_no_kids')[0].submit(); 我在您的表单中添加了一个id,并在锚定标签上调用了一个函数单击以提交表单数据: <form method="post" name="frm_no_kids" class="getstarted" action="step1.php"> <input type="hidden" id="price_val
document.getElementsByName('frm_no_kids')[0].submit();
我在您的表单中添加了一个id,并在锚定标签上调用了一个函数单击以提交表单数据:
<form method="post" name="frm_no_kids" class="getstarted" action="step1.php">
<input type="hidden" id="price_value" name="fee" value="<?php echo encrypt(499); ?>">
<input type="hidden" id="divorce_type" name="divorce_type" value="no_kids">
<a class="btn border-btn yellow-btn started-hover" title="Get Started" href="javascript:document.getElementsByName('frm_no_kids')[0].submit();">Get Started </a>
</form>
在表单中使用一个实际的提交按钮,而不是像提交按钮一样的超链接,会更有意义。如果希望对显示/格式进行更多控制,可以使用
或
如果设置为使用非提交按钮(如超链接),则最好为表单提供自己的ID:
<form method="post" name="frm_no_kids" id="frm_no_kids" class="getstarted" action="step1.php">
<input type="hidden" id="price_value" name="fee" value="<?php echo encrypt(499); ?>">
<input type="hidden" id="divorce_type" name="divorce_type" value="no_kids">
<a class="btn border-btn yellow-btn started-hover" title="Get Started" href="javascript:;" onclick="submitData()">Get Started </a>
</form>
<script>
function submitData(){
document.getElementById("frm_no_kids").submit();
}
</script>
在From中添加一个ID,并在javascript中使用该ID
document.getElementById("frm_no_kids_submit").addEventListener("click", function(){
document.getElementById("frm_no_kids").submit();
});
不要使用那样的内联事件,这是一种糟糕的做法。使用外部事件处理程序但目前,请为我提供此错误的解决方案。@neha910您应该积极接受此建议。@Tiger,是的,确实如此,但当时我很匆忙,谢谢您的评论。是的,非常感谢,不是它工作得很好。Thanx再一次:)@Ravi
<form method="post" id="frm_no_kids" name="frm_no_kids" class="getstarted" action="step1.php">
<input type="hidden" id="price_value" name="fee" value="<?php echo encrypt(499); ?>">
<input type="hidden" id="divorce_type" name="divorce_type" value="no_kids">
<a class="btn border-btn yellow-btn started-hover" title="Get Started" href="javascript:document.getElementById('frm_no_kids').submit();">Get Started </a>
</form>
<form method="post" id="frm_no_kids" name="frm_no_kids" class="getstarted" action="step1.php">
<input type="hidden" id="price_value" name="fee" value="<?php echo encrypt(499); ?>">
<input type="hidden" id="divorce_type" name="divorce_type" value="no_kids">
<a id="frm_no_kids_submit" class="btn border-btn yellow-btn started-hover" title="Get Started" href="#">Get Started </a>
</form>
document.getElementById("frm_no_kids_submit").addEventListener("click", function(){
document.getElementById("frm_no_kids").submit();
});
<form method="post" name="frm_no_kids" id="frm_no_kids" class="getstarted" action="step1.php">
<input type="hidden" id="price_value" name="fee" value="<?php echo encrypt(499); ?>">
<input type="hidden" id="divorce_type" name="divorce_type" value="no_kids">
<a class="btn border-btn yellow-btn started-hover" title="Get Started" href="javascript:;" onclick="submitData()">Get Started </a>
</form>
<script>
function submitData(){
document.getElementById("frm_no_kids").submit();
}
</script>