|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Retrieve form value from insert (post method - multipart form data) record
Hi,
I've got an insert record page that use the post method - multipart form data and i want to retrieve the formvalues on the redirect page. I tried several things, just #form.fieldname# and also with the request command, what's the proper way to do this? Can anyone help? ![]() |
|
#2
|
|||
|
|||
|
If you have a form field called firstName and you post it, on the action page you reference that value as #form.firstName#.
__________________
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
|
|||
|
|||
|
On the insert record page i have this form element:
<input name="checkbox" type="checkbox" class="invoervelden" value="checkbox" checked> This is a piece of code from the action page: <cfoutput> <form action="#CurrentPage#?#CGI.QUERY_STRING#" name="form1" method="POST"> ------------------------------------------------------ <input name="checkbox" type="hidden" id="checkbox" value="#form.checkbox#"> ------------------------------------------------------ <input type="hidden" name="MM_UpdateRecord" value="form1"> </form></cfoutput> When i try to run this i get the following error: ------------------------------------------------------ Element CHECKBOX is undefined in FORM. The error occurred in C:\data\websites\spiriloged\pages\updatebermail.cfm: line 73 71 : <cfoutput> 72 : <form action="#CurrentPage#?#CGI.QUERY_STRING#" name="form1" method="POST"> 73 : <input name="checkbox" type="hidden" id="checkbox" value="#form.checkbox#"> 74 : <input type="hidden" name="MM_UpdateRecord" value="form1"> 75 : </form></cfoutput> What do i do wrong? ![]() |
|
#4
|
|||
|
|||
|
In HTML, if a checkbox or radio button are not checked/selected, that variable is not passed to the action page. So on the action page you'd want to do:
<cfif structKeyExists( form, 'checkbox' )> <input name="checkbox" type="hidden" id="checkbox" value="#form.checkbox#"> </cfif> |
|
#5
|
|||
|
|||
|
I tried to use the code, now i get no error but also no value in the database from checkbox, it doesn't mather if the checkbox is selected or not...
Any ideas? |
|
#6
|
|||
|
|||
|
Isn't there a way to capture some data from the insert record action?
|
|
#7
|
|||
|
|||
|
I don't understand what you're asking. You seem to be talking about two different things: referencing a form variable on an action page, and getting information about a database insert.
|
|
#8
|
|||
|
|||
|
Ok, i try to explain better,
I have a page that holds an insert record behaviour, when i submit that page the data is written to the database. Then the page goes to another page where i want to retrieve the value from a form field from the first page (insert record page) You should say simply do #form.fieldname# but it isn't working. So the problem is how can i get the form value from the insert record page to the second page, how can i retrieve that value there? |
|
#9
|
|||
|
|||
|
How is processing being shifted from the database insert page to the form page? It sounds like you are using cflocation, and if that is the case, then you won't be able to access the form variables from the first page any longer, those will die on the database insert page, which is what they are supposed to do. If you want to use cflocation to the form page again, you'll need to manually track the original form variables, either by appending them to the cflocation URL, or by storing them in a persistant scope (session, client, cookie, etc.). Or, assuming you just inserted the form data into the database, just query the data back from the database.
|
|
#10
|
|||
|
|||
|
Ys i'm using cflocation, so that's the problem then...
Ok i'm gonna use your info and try to fix it, thanks |
|
#11
|
|||
|
|||
|
Ok got it working, i used the query back method you told.
|
|
#12
|
|||
|
|||
|
Yep, form variables only exist for the duration of a single HTTP request. When you initiate a cflocation, you are performing an HTTP redirect which creates a new HTTP request. Once you do that, you form variables are gone. The only way to keep track of them at that point is to persist them somehow, and using the database is exactly what it is for! Glad you got it working.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Retrieve form value from insert (post method - multipart form data) record |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|