Jump to content

Recommended Posts

Here is the code for test.html:

<html>
<head><title></title></head>
<body>

<script type="text/javascript">
function OnSubmitForm(){
	document.myform.action ="insert.html";
	return true;
}
</script>

<form name="myform" onsubmit="return OnSubmitForm()" method="get">
<input type='radio' name='Search' value='test'>test</input>
</form>

<a href='javascript:document.myform.submit()'><img src='images/buttonnext.jpg'></a>

</body>
</html>

 

The way I want it to work:

when the img (buttonnext.jpg) is clicked, the form is submitted.  When the form is submitted it runs the javascript, which sets the action to be that insert.html is loaded.  i.e. the end result should be to redirect to insert.html?Search=test

 

The way that it is working now:

the page is redirected to test.html?Search=test

 

What do I need to change to accomplish my goal?

Solved.  Changing the href to:

 

<a href='javascript:if(OnSubmitForm())document.myform.submit()'>

 

gets it working!

 

What's the point of setting the action with a javascript function? Just seems like code you don't need. You can just as easily use the standard action attribute and submit the form on an external click event. fyi

I was only showing a simplified version of the page.  The full version sets the action to one of multiple things based on some criteria.

I was thinking there may be more to it. Glad you got it sorted. Sorry if I informed you of something you already knew. :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.