|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Javascript Help with a form using Coldfusion
I have a form in coldfusion that uses two javascript functions depending on what button the user clicks. Here is the form:
<form action ="digitalSignForm.cfm" method="post" name="approveDenyForm"> <input type="hidden" name="materialId" value=""> <input type="hidden" name="approveDeny" value=""> <input type="hidden" name="facilityMessage" value=""> <input type="hidden" name="forwardTo" value="msdsFacilityApproval_action.cfm"> <table width="85%" border="1" cellpadding="3" cellspacing="0"> <tr> <td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">Material</span></div></td> <td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">Mfg</span></div></td> <td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">Issue Date</span></div></td> <td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">Shelf Life</span></div></td> <td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">First Aid</span></div></td> <td width="16%"><div align="center" class="style18 style19"><span style="font-weight: bold">Approve</span></div></td> </tr> <cfoutput query="pendingMSDS"> <tr> <td><span class="style7">#pendingMSDS.Material# <cfif #pendingMSDS.DocLink# gt "//filer/report_library" > <a href="#pendingMSDS.DocLink#" target="#pendingMSDS.MaterialId#">View MSDS</a> </cfif> </span></td> <td><span class="style7">#pendingMSDS.Mfg#</span></td> <td><span class="style7">#dateformat(pendingMSDS.IssueDate,'mm/dd/yyyy')#</span></td> <td><span class="style7">#pendingMSDS.ShelfLife#</span></td> <td><span class="style7">#pendingMSDS.FirstAid#</span></td> <td><span class="style7"><input type="button" name="approve" value="Approve" onclick="approveSubmit(#pendingMSDS.materialId#, '#pendingMSDS.material#');"><input type="button" name="deny" value="Deny" onclick="denySubmit(#pendingMSDS.materialId#, '#pendingMSDS.material#');"></span></td> </tr> </cfoutput> </table> </form> Here are the two javascript functions: <SCRIPT LANGUAGE = "JavaScript"> function approveSubmit(materialId, materialName){ document.approveDenyForm.materialId.value=materialId; document.approveDenyForm.approveDeny.value=1; document.approveDenyForm.facilityMessage.value='Please reconfirm the approving of MSDS ' + materialName; document.approveDenyForm.submit(); } function denySubmit(materialId, materialName){ document.approveDenyForm.materialId.value=materialId; document.approveDenyForm.approveDeny.value=0; document.approveDenyForm.facilityMessage.value='Please reconfirm the denying of MSDS ' + materialName; document.approveDenyForm.submit(); } </SCRIPT> What I want to do is, if the user clicks the 'Deny' button, I want it to first go to an intermediate page and then from there continue on with the normal form procedure. I have no idea how to do this as I am not too familiar with javascript. Any help would be greatly appreciated. |
|
#2
|
|||
|
|||
|
My knowledge of Javascript is fairly limited as well, so I won't be able to help on this one. If you don't get much response you probably want to post this in the Javascript forum.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Yea I actually posted it at both places. Figured it wouldnt hurt. Thanks anyways.
|
|
#4
|
||||
|
||||
|
Not quite sure what you are trying to do.
Do you want it so that if someone hits one of the two buttons, it will go to a process page, and then after processing, come back to the original and continue processing what was left? |
|
#5
|
|||
|
|||
|
How the form works right now, is that if u click one of the buttons, it goes to a sign page where the user digitally signs off on it and then forwards it to an action page. However, what I want to do is for one of the buttons, when a user clicks it, i want it to go first to a intermediate page where it does some action and what not and then goes to the sign page which will get forwarded to the action page.
|
|
#6
|
||||
|
||||
|
Well if you don't want to use seperate forms for each button, you can use javascript to fire off the to the next page. you can use location.replace("index.cfm"). However, this is not a submit, it is a redirect, so there will be no form values.
|
|
#7
|
||||
|
||||
|
Why not just add something to a hidden form field if it's denied and have CF look for that when the next page loads? The problem is that you will have to re-populate the form for the next page, but this is just a matter of re-creating it and re-hashing it in: no big deal.
<cfif Len(Form.denied) GT 1> INTERMEDIATE CONTENT<br> <form> << PUT YOUR FORM VARIABLES HERE >> <input type="submit" value="Continue"> </form> <cfelse> <cfquery> YOUR UPDATE QUERY </cfquery> REGULAR CONTENT </cfif> Hope that works. -colin |
|
#8
|
|||
|
|||
|
You can change the action attribute of the form through javascript:
<SCRIPT LANGUAGE = "JavaScript"> function approveSubmit(materialId, materialName){ document.approveDenyForm.materialId.value=materialId; document.approveDenyForm.approveDeny.value=1; document.approveDenyForm.facilityMessage.value='Please reconfirm the approving of MSDS ' + materialName; document.approveDenyForm.submit(); } function denySubmit(materialId, materialName){ document.approveDenyForm.materialId.value=materialId; document.approveDenyForm.approveDeny.value=0; document.approveDenyForm.facilityMessage.value='Please reconfirm the denying of MSDS ' + materialName; document.approveDenyForm.action='intermediatepage.cfm'; document.approveDenyForm.submit(); } </SCRIPT> Hope it helps...
__________________
** Don't expect me to code your needs, but if I am able to help, I'm willing. Shout, grab and use the hand! ** Man can no more own the land we walk upon, as they can lay claim on the air that we breath ** DeepDown I'm addicted to structures.... ohw and music ![]() ** Almost forgot I had an account here [*o*] |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Javascript Help with a form using Coldfusion |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|