Jump to content


Photo

How to use javascript to change form action?


  • Please log in to reply
1 reply to this topic

#1 q1234ask

q1234ask
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 27 March 2006 - 11:03 PM

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

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 28 March 2006 - 01:46 AM

This is the PHP forum, please post your Javascript questions in the Javascript forum.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users