我有一个模板,其中创建了一个使用css链接的按钮,因此我希望该按钮在该链接上提交表单,我试过但没有任何反应,请帮助我, 感谢。
<?php
$errors = array();
if(isset($_POST['submit'])=="Find Moving Service") {
echo 'Form Submitted!';
}
?>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post" name="myForm" id="myForm" >
<input type="hidden" name="submit" value="Find Moving Service" />
<select name="category">
<option value="" >Select a category</option>
<option value="Local Movers" >Local Movers</option>
<option value="Long Distance Movers" >Long Distance Movers</option>
<option value="Office Movers" >Office Movers</option>
<option value="International Movers" >International Movers</option>
</select>
<a href="javascript: submitform()" title="Find Moving Service" class="button_big big_green float-right">Find Moving Service<i></i></a>
</form>
<script type="text/javascript">
function submitform()
{
if(document.myForm.onsubmit())
{
document.myForm.submit();
}
}
</script>
答案 0 :(得分:3)
<a href="#" onclick="document.myForm.submit();return false;" title="Find Moving Service" class="button_big big_green float-right">
你不需要这个功能。
答案 1 :(得分:-1)
尝试将您的javascript代码放在body标记
之前