Jump to content

How to use javascript to change form action?


q1234ask

Recommended Posts

Hey,

I need to change the form action to different page according to the selinsutype dropdown selection.
I have the javascript code but it does not work. it goes no where.

What is wrong? Please advise. Thanks!!!

javascript code here:

function submitCurrentForm()
{
form=document.form1;
var alertmsg='';
var mstr="Please correct the following fields to continue:";
if (form.elements['txtfdate'].value=='')
{
alertmsg+="\nFrom Date";
}
if (form.elements['txttodate'].value=='')
{
alertmsg+="\nTo Date";
}
var selected_index=form.selinsutype.selectedIndex;
var insutype=form.selinsutype[selected_index].text;
if(insutype=="MEDICARE")
form.Action="revenueoutput.php";
if(insutype=="MEDICAID")
form.Action="medicaidrevenue.php";
if(insutype="PRIVATE")
form.Action="privatepaidrpt.php";

if(alertmsg.length>4)
{
mstr+=alertmsg;
alert (mstr);
}else {form1.submit();}
}
Link to comment
Share on other sites

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.