Reputation: 2499
Beginner question: I would like to pass in window.location.hash to my form action parameter. How can I do this with a javascript call?
my current non-working code is:
<form method="POST"
action="j_security_check"+window.location.hash>
Upvotes: 1
Views: 642
Reputation: 22241
<form name="hello" method="POST" action="">
Hello
</form>
<script>
document.forms.hello.action = 'j_security_check'+window.location.hash;
alert(document.forms.hello.action);
</script>
Proof: http://jsfiddle.net/2QE6h/1
Upvotes: 0
Reputation: 8086
Your javascript needs to be based on some kind of event. So you might want to do it when your submit button is pressed or something:
<form method="POST" action="">
<input type="submit" value="Submit" onclick="this.form.action = 'j_security_check'+window.location.hash" />
.....
Upvotes: 3