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();}
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.