Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assigning javascript variable into coldfusion

Status
Not open for further replies.

dev29

Programmer
Jun 11, 2011
1
US
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>
 
Several problems.
I see it's a fragment of your code; posting the whole document (in a
Code:
tag pair) is advised.

1. I don't see where the js function "loaddefimages" is being called so there is no way it will execute. Whole document might show that...

2. Are you sure your </script> tag is correctly placed? You have html and cfml tags placed after the end of the loaddefimages function and before the end of the script tag. That will most likely cause a js error.

Many more observations but let's "eat the elephant" one bite at a time... post the whole document if you want some help understanding how to mix js and coldfusion.

Lyndon

---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top