Jump to content

Archived

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

q1234ask

How to use javascript to change form action?

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

Share this post


Link to post
Share on other sites
This is the PHP forum, please post your Javascript questions in the Javascript forum.

Ken

Share this post


Link to post
Share on other sites

×

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.