ColdFusion doesn't work that way.  By the time the browser gets to the point
of running any JavaScript, all of the ColdFusion processing for the page has
been done.  There is some things you could use to accomplish what it looks
like what you're trying to do.

First, it looks like you don't even need it as a ColdFusion variable, since
you're just writing the URL to the page.  In that case, since you already
have that value in JavaScript, you could just write the value to the page
using JavaScript.  (Also, note that the code you provide isn't going to work
correctly anyway, because you have HTML mixed in between your opening and
closing <script> tags).

If you actually do need it as a CF variable for some reason, you could use
Ajax to set the value (though it would have to be in a persistent scope,
such as a session variable). Or, since you just have the value hard-coded in
the example, you could just hard-code it again when setting the CF variable
(if your intention is to hard-code it).

Scott

On Sat, Jun 11, 2011 at 8:41 PM, Gunjan Upadhayay <
29gunjanupadha...@gmail.com> wrote:

>
> I am trying to assign javascript variable into cold fusion .But it's not
> working as expected.Please assist
>
> <cfif ADerror eq "Success" and  len(trim(getDetails.userPrincipalName)) gt
> 0 >
>
>  <cfset userDomain = listGetAt(listGetAt(getDetails.userPrincipalName, 2,
> "@"), 1, ".") />
>  <cfset userID = listGetAt(getDetails.userPrincipalName, 1, "@") />
>  <cfset userDomain_ID = userDomain & "_" & userID />
>  <cfoutput>userDomain_ID: #userDomain_ID#<br/></cfoutput>
>  <cfif len(trim(userDomain_ID)) >
>  <script language='javascript'>
>     function loaddefimages(Id,domain)
>      {
>          document.getElementById(Id).src="
> http://mysites10.test.com/Profile%20Pictures/
> "+domain+"_#userID#_LThumb.jpg";
>          var temp = document.getElementById("jsURL").value ="
> http://mysites10.test.com/Profile%20Pictures/
> "+domain+"_#userID#_LThumb.jpg";
>      }
>
>  <img id="img1" src="
> http://mysites10.test.com/Profile%20Pictures/NA_#userID#_LThumb.jpg";
> alt=""
>  onerror="javascript:loaddefimages('img2','AM');" />
>  <img id="img2" src="" alt=""
> onerror="javascript:loaddefimages('img3','CSA');" />
>  <img id="img3" src="" alt="" onerror="javascript:loaddefimages('img4',
> 'AP');" />
>  <img id="img4" src="" alt="" onerror="this.src='
> http://sme-d.am.test.com/#right(attributes.global_id, 8)#.jpg'"/>
>  <cfinput name = "jsURL" id = "jsURL">
>  <cfset Variables.photoURL = #temp# />
>  <cfoutput>#photoURL#</cfoutput>
>        </script>
>      </cfif>
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345189
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to