Hey fellas, I need some help doing on action changes

This is what I got. I have a loop that has the form name "autoEmailRedirect"

<form name="autoEmailRedirect" method="post"  action="autoEmailContact.jsp">
              <td valign="top" class="paddingLeft10 paddingTop9">
<div class="paddingBottom2 boldFont paddingTop20"><%=(String)autoName.elementAt(i)%></div>
</td>
<td class="paddingTop9 paddingLeft" valign="top">
<div class="paddingBottom2 paddingTop20"><%=(String)autoEmail.elementAt(i)%></div>
</td>
<td class="paddingLeft11 paddingTop9 paddingBottom13 width66" valign="top">
<select name="actionChoice" size="1">
<option value="1">Get Details about this customer</option>
<option value="2">E-mail Username/Password to customer</option>
<option value="3">E-mail link to Login page to customer</option>
<option value="4">Un-subscribe this customer</option>
</select>
<input type="submit" name="method" value="Go" onClick="javascript:doCustomRedirect();" class="butn smallbutn3 last"> 
<input type="hidden" name="email" value="<%=(String)autoEmail.elementAt(i)%>"/>
<INPUT TYPE="hidden" NAME="username" VALUE="<%=username%>"/>
<INPUT TYPE="hidden" NAME="password" VALUE="<%=password%>"/>
</td>
</form>

So if it has 3 instances...it prints out 3 times.


Now the javascript I have is

function doCustomRedirect()
	{
  var frm = document.forms["autoEmailRedirect"];
    if(frm.actionChoice.value == "1")
  {
    document.forms["autoEmailRedirect"].action = 'http://<%=javaAdminServer%>/JAABA/jsp/cpanel/autoEmailContact.jsp'; 
    document.forms["autoEmailRedirect"].submit();
  }
  if (frm.actionChoice.value == "2")
  {
    document.forms["autoEmailRedirect"].action = 'http://<%=javaAdminServer%>/JAABA/jsp/cpanel/cp-ecomm.jsp'; 
    document.forms["autoEmailRedirect"].submit();
  }
   if (frm.actionChoice.value == "3")
  {
    document.forms["autoEmailRedirect"].action = 'http://<%=javaAdminServer%>/JAABA/jsp/cpanel/changeAccount.jsp'; 
    document.forms["autoEmailRedirect"].submit();
  }  
  if (frm.actionChoice.value == "4")
  {
    document.forms["autoEmailRedirect"].action = 'http://<%=javaAdminServer%>/JAABA/jsp/cpanel/autoContactDelete.jsp'; 
    document.forms["autoEmailRedirect"].submit();
  }
}

This doesnt seem to be working at all..it goes to the page "autoEmailContact.jsp". no matter what option I choose

now If I do " document.forms[0].action"

I can get the 1st form to work...but the other 2 dont work


..and Im guessing because all the forms have the same name and it doesnt know which one to access????

Help a brotha out

thanx

Uncomment whatever you want, try, think. :-)

<script>

var arrURL = new Array('http://server/page0.jsp' ,'http://server/page1.jsp' ,'http://server/page2.jsp' ,'http://server/page3.jsp');

function doCustomRedirect(frm)
{ 
/*
  if (frm.actionChoice.value == "0") frm.action = 'http://server/page0.jsp'; 
  if (frm.actionChoice.value == "1") frm.action = 'http://server/page1.jsp'; 
  if (frm.actionChoice.value == "2") frm.action = 'http://server/page2.jsp'; 
  if (frm.actionChoice.value == "3") frm.action = 'http://server/page3.jsp'; 
//*/
/*
  switch (frm.actionChoice.value)
  { case "0": frm.action = 'http://server/page0.jsp'; break
    case "1": frm.action = 'http://server/page1.jsp'; break
    case "2": frm.action = 'http://server/page2.jsp'; break
    case "3": frm.action = 'http://server/page3.jsp'; break
    default : ;
  }
//*/
//*
  frm.action = arrURL[frm.actionChoice.value]
//*/
  frm.submit();
} 
</script>
</head>
<body>
<form name="autoEmailRedirect" method="post"  action="autoEmailContact.jsp">

<select name="actionChoice" size="1">
  <option value="0">Get Details about this customer</option>
  <option value="1">E-mail Username/Password to customer</option>
  <option value="2">E-mail link to Login page to customer</option>
  <option value="3">Un-subscribe this customer</option>
</select>
<input type="button" name="method" value="Go" onClick="doCustomRedirect(this.form);" > 
<input type="hidden" name="email" value="autoEmail">
<INPUT TYPE="hidden" NAME="username" VALUE="username">
<INPUT TYPE="hidden" NAME="password" VALUE="password">

</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.