I have three forms, not always all three will be defined (in many cases it's just two), but in any scenarios I would like to send them. Action page will be execute something. Current script works fine with 1 or 2, but not 3 forms.
Any chance that it can be done with simple JS or CF only? Or may be there is better way to handle this?
<form id="CreateTask1" action=action.cfm>
<form id="CreateTask2" action=action.cfm>
<form id="CreateTask3" action=action.cfm>
<script type="text/javascript">
function submitforms() {
if (document.getElementById('CreateTask1') != null)
document.forms.CreateTask1.submit();
window.setTimeout(function() {
if (document.getElementById('CreateTask2') != null)
document.forms.CreateTask2.submit();
}, 100);
window.setTimeout(function() {
if (document.getElementById('CreateTask3') != null)
document.forms.CreateTask3.submit();
}, 100);
}
</script>
I suppose you could
<form id="CreateTask1" action="action.cfm" target="iframe1"></form>
<iframe name="iframe1" src="blank.html"></iframe>
<form id="CreateTask2" action="action.cfm" target="iframe2"></form>
<iframe name="iframe2" src="blank.html"></iframe>
<form id="CreateTask3" action="action.cfm" target="iframe3"></form>
<iframe name="iframe3" src="blank.html"></iframe>
<script type="text/javascript">
function submitforms() {
if (document.getElementById('CreateTask1') != null)
document.forms.CreateTask1.submit();
window.setTimeout(function() {
if (document.getElementById('CreateTask2') != null)
document.forms.CreateTask2.submit();
}, 100);
window.setTimeout(function() {
if (document.getElementById('CreateTask3') != null)
document.forms.CreateTask3.submit();
}, 100);
}
</script>