I have this javascript function that submits a form after an onclick event. The form's name is "postdata". It works fine.
<script>
function submitform() {
document.postdata.submit();
}
</script>
I want to change the function so I can use it for any form. I modified the function as follows:
<script>
function submitform(formname) {
document.formname.submit();
}
</script>
It doesn't work, and I don't know why. Is my syntax wrong?
I know that the form name is being passed to the function successfully. If I temporarily change the function to this:
<script>
function submitform(formname) {
alert(formname);
}
</script>
...the alert contains "postdata" as expected.
Thanks for your suggestions!