Forum Moderators: open
Not sure if this is the right forum for this question, but I couldn't work out if there was a better one.
I have a page with a form in it. Using a JavaScript free method for making two related select boxes (i.e. where selecting something in one select box changes the contents of the second one) requires me to not have the "action" attribute of the form tag defined. The problem with this is that when I then go to submit the form, it doesn't know where to go.
So I've been trying to find information on the form.submit() function - the key word here is "trying". So maybe someone can tell me: is it possible to pass as an argument to this function a location for the form to submit to? I've tried a couple of ways of doing it, and it's not working for me.
Alternatively, if there is a better way of doing this I would love to hear it.
Cheers,
Seona.
<form method="post" name="theForm" onSubmit="return newJump()" action="" etc... >
<select name="jump"> This works with drop-down menus - not sure about other forms. The JavaScript then passes the user to the correct page:
function newJump()
{if (document.theForm.jump)
{target = document.theForm.jump.options[document.theForm.jump.selectedIndex].value;
if (target!= "nought")
{top.location = target;
window.target;}
window.self.location=target;
return false;}
return true;}
You can assign the form's action in javascript. So, with a little effort, you can choose different actions depending contents.
You need to assign the following:-
<FORM ONSUBMIT="return submitform(this);">function submitform(form)
{ with (form) {
......action = '/cgi-bin/.......';
return 1; { return zero to stop form submission }
}}
Kaled.
<FORM action="handler.cgi" onSubmit="return checkForm(this);">
...
</FORM>