Re: iframe cfscript getting parent form field values SOLVED

2010-02-21 Thread Dan Blickensderfer

I just wanted to give you an update on how I was able to get this to work.

On my iframe page, this is all I had to do to get my javascript variable to 
assign it to a cf variable.

Thanks for those to helped.
Dan


cfscript
getdatefield = ('
   script language=JavaScript
   !--
   document.write(parent.document.eform.part_date.value);
   //--
   /script
');
/cfscript
cfoutput#getdatefield#/cfoutput 




~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:330995
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: iframe cfscript getting parent form field values SOLVED

2010-02-21 Thread Dominic Watson

A word of warning; know the difference between client side and server side
code. While you have solved your problem, you have not assigned the date
value to a coldfusion variable at all here ('getdatefield' will never equal
the date that someone has entered). Everything in the cfscript is as good as
pointless, simply outputting the following is equivalent (and could be done
in a plain html page):

script language=JavaScript
 document.write(parent.document.eform.part_date.value);
/script

Very roughly how an HTTP request works through a web browser (HTTP requests
do not need a web browser, but this is useful for this example):

1. Client browser makes a request to a server (someone has entered your url,
submitted a form or clicked a link to your url)
2. Server processes the client input and sends back a response -  usually an
HTML page, perhaps with some javascript
3. Client browser interprets that response - renders html, processes
javascript, etc.

ColdFusion only plays a part in step 2. So, in order for the ColdFusion
variable, getDateField, to actually be assigned the user-entered value, that
data must be sent in step 1. The client MUST send the data to the server in
order for ColdFusion to have any access to it.

In your example:

1. Browser sends a request to your server (the url of the iframe)
2. ColdFusion responds with some html including the javascript above
3. Browser executes the javascript and retrieves the user value from the
parent document

The user value has never been sent to ColdFusion.

Grok this absolutely fundamental concept (seemingly many people never do)
and things should become clearer very quickly!

HTH

Dominic

On 21 February 2010 16:27, Dan Blickensderfer d...@blickensderfer.comwrote:


 I just wanted to give you an update on how I was able to get this to work.

 On my iframe page, this is all I had to do to get my javascript variable to
 assign it to a cf variable.

 Thanks for those to helped.
 Dan


 cfscript
getdatefield = ('
   script language=JavaScript
   !--
   document.write(parent.document.eform.part_date.value);
   //--
   /script
');
/cfscript
cfoutput#getdatefield#/cfoutput




 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:330999
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4