Javascript document.form.submit() not working with Firefox 4.0 and IE8
I'm trying to submit a form with javascript. Works fine with Firefox 3.6, but doesn't work in Firefox4.0 and IE8.
Code:
<table>
<tr>
<td>
<form action='results.html' method='post' target='_blank' id='<% $question->{ QuestionID } %>'>
<input type='hidden' name='SurveyID' value='<% $surveyid %>'
<input type='hidden' name='responses' value='<% join ",", map { $_->{ srid } } @textresults %>'/>
<input type='hidden' name='question' value='<% $question->{ QuestionID } %>'/>
Total Responses: (< a href='javascript: submitForm("<% $question->{ QuestionID } %>");' >View All< /a>)
</form>
</td>
</tr>
</table>
Javascript:
<script type='text/javascript'>
function submi开发者_高级运维tForm(id) {
document.getElementById(id).submit();
}
</script>
Any Idea what is wrong?
First of all close the first input tag like this: <input type='hidden' name='SurveyID' value='<% $surveyid %>'/>
. Also remove the spaces from the a
tag, here: <a href
and here: </a>
What happens if you add a name property to the form and submit the form like this:
function submitForm(id) {
document.formname.submit();
}
精彩评论