1

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>
2

2 Answers 2

3

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" />

.....
Sign up to request clarification or add additional context in comments.

1 Comment

-1 The javascript doesn't need to be based on any event to execute.
0
<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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.