You cannot invoke Javascript functions in standard HTML attributes other than onXXX
. Just assign it during window onload.
<script type="text/javscript">
window.onload = function() {
document.myform.action = get_action();
}
function get_action() {
return form_action;
}
</script>
<form name="myform">
...
</form>
You see that I've given the form a name
so that it's easily accessible in document
.
Alternatively, you can also do it during submit
event:
<script type="text/javscript">
function get_action(form) {
form.action = form_action;
}
</script>
<form onsubmit="get_action(this);">
...
</form>