i have a page, which has 2 links (search, normal button), both redirects are different url, on search click, search page should get open and on other button, form action should be set, now the problem is when i click on any of the button the form action is fired and page is redirect to the form action url.
here’s the scenario:
<script type="text/javascript">
function get_action(form) {
form.action = "http://google.com";
}
</script>
<form onsubmit="get_action(this);">
<input type="submit" name="submit" value="submit">
<input type="button" id="btnClick" value="click" />
</form>
i guess i would need to set the action url at the runtime, so that when i click on the submit button only then the form action should be raised.
Is there any reason you dont want to make “search” and “click” as buttons and add a javascript click handler on both these buttons. This way you will be able to do a document.location on both the buttons.
To avoid the form from posting, add a javascript handler for onSubmit and return false from this method.