I have some old code with document.write in it.
<script type="text/javascript" language="JavaScript1.2">
document.write('<form name="InvGenPayDonation" action="'+PostURL+'" onsubmit="return validateForm();" method="POST">');
</script>
How can I replace action with a javascript variable that has been determined when the page was loaded? Here is that code, which is not part of a function. (I've substituted names, so the substr indexes are not correct, but I'm sure you get the point.)
// Check where we came from so that we can go to the right spot when the
// form gets posted from outside of our HTML tree.
var PostURL = '/event.php';
if (window.location.href.substr(0, 21) == 'http://10.10.10.10:80')
PostURL = 'http://10.10.10.10:8580/event.php';
else if (window.location.href.substr(0, 14) == 'http://webapps')
PostURL = 'http://10.100.0.11:8580/event.php';
else if (window.location.href.substr(0, 7) == 'webapps')
PostURL = 'http://10.10.10.10:8580/event.php';
else if (window.location.href.substr(0, 10) == 'http://www')
PostURL = 'https://secure.french.toast.new_zeland.france/event.php';
I'd like PostURL to go into the form's action. If I can do that without document.write, that would be great. I just need some help. Thanks.