I am trying to assign javascript variable into coldfusion .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=" var temp = document.getElementById("jsURL").value =" }
<img id="img1" src=" 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=' 8)#.jpg'"/>
<cfinput name = "jsURL" id = "jsURL">
<cfset Variables.photoURL = #temp# />
<cfoutput>#photoURL#</cfoutput>
</script>
</cfif>
<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=" var temp = document.getElementById("jsURL").value =" }
<img id="img1" src=" 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=' 8)#.jpg'"/>
<cfinput name = "jsURL" id = "jsURL">
<cfset Variables.photoURL = #temp# />
<cfoutput>#photoURL#</cfoutput>
</script>
</cfif>