Click to See Complete Forum and Search --> : Help with Form Action


ejrhodes
05-13-2003, 02:05 PM
Guys,
Here is my current code:


<form method="POST" action="pm.asp">
<td align="center">
<input type="text" name="ID" size="5" maxlengh="5"><br>
<input src="images/edit_btn.gif" type="image" alt="Edit Project" onClick="this.form.action.value='editproject';">
<input src="images/ezedit_btn.gif" type="image" alt="EZ edit" onClick="this.form.action.value='ezedit';">
<input src="images/jco_btn.gif" type="image" alt="Edit JCO" onClick="this.form.action.value='editjco';">
<input src="images/finance_btn.gif" type="image" alt="Edit Finance" onClick="this.form.action.value='editfinance';">
<input src="images/enumber_btn.gif" type="image" alt="eNumber" onClick="this.form.action.value='enumber';">
<input src="images/report_btn.gif" type="image" alt="Report" onClick="this.form.action.value='projecttime';">
<input type="hidden" name="action" value=""> </form

The action that happens now is that when the image is clicked, the hidden form attribute action is populated and the page that is called uses that action form value to make decisions. What I am wondering is it is possible to change the URL that the form posts to on click as well?

ie

On EZ EDit Click
Hidden Value="ezedit"
URL="test.asp"

but
Finance on Click
Hidden Value="finance"
URL="financetest.asp"


I realize that there is an action on the form and an action hidden form value in this case. Any suggestions?

AdamBrill
05-13-2003, 03:55 PM
So, basically you want to change the action of the form? Try this:

document.formname.action="financetest.asp";

ejrhodes
05-13-2003, 04:31 PM
Originally posted by AdamBrill
So, basically you want to change the action of the form? Try this:

document.formname.action="financetest.asp";

What happened was I had a conflict with the name Action. As soon as I reneamed the hidden value ACTION, everything worked. Javascript's case sensitivity got me :)

Follow up questions

I have an input box called ID. How do I pull the value entered into this box into a hidden value called Project on click?

THanks

pyro
05-13-2003, 04:37 PM
onclick="document.formname.Project.value=document.formname.ID.value;"

ejrhodes
05-13-2003, 04:46 PM
Originally posted by pyro
onclick="document.formname.Project.value=document.formname.ID.value;"

thanks a lot that solved it