Cold Fusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingCold Fusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 11th, 2004, 10:29 AM
mtennor mtennor is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Maryland
Posts: 3 mtennor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Access Cold Fusion array values from Javascript

I have created an array in Cold Fusion and I would like to know how to access the array values from a javascript.

Any help would be greatly appreciated.

Thanks,

Mike

Reply With Quote
  #2  
Old September 23rd, 2004, 12:28 PM
shawn shawn is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 24 shawn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I haven't tried accessing an array, but typically you just wrap the variable with <cfoutput></cfoutput> tags. Or you can wrap the entire script in the <cfoutput> tags.


Ex.
<script>
<cfoutput>
alert("My coldfusion variable is: #cfvariable#");
</cfoutput>
</script>

Reply With Quote
  #3  
Old September 24th, 2004, 04:03 PM
mtennor mtennor is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Maryland
Posts: 3 mtennor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Shawn,

Have you actually tried to do this because I can not get your suggestion to work? I'm just trying to get to the value a regular variable (not an arrary value) created in the Cold Fusion part of the program by the script part of the program. I've tried this several different ways with no luck. Do you have any idea why this doesn't work?

Thanks,
Mike

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>

<script>
function showArray(){
<cfoutput>
alert('#ab#');
</cfoutput>
}
</script>

</head>
<body>
<cfset ab = 'Goodbye'>
<cfform action="GoNowhere.cfm" method="POST" enablecab="Yes">
<input type="text" name="test" size="5" onChange="showArray();">
</cfform>
</body>
</html>

Reply With Quote
  #4  
Old December 8th, 2004, 05:56 PM
neelcf neelcf is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 1 neelcf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,
Cold Fusion variable should be declared before accessing in javascript. Below code should work.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<cfset ab = "Goodbye">

<script>
function showArray(){
<cfoutput>
alert('#ab#');
</cfoutput>
}
</script>

</head>
<body>

<cfform action="GoNowhere.cfm" method="POST" enablecab="Yes">
<input type="text" name="test" size="5" onChange="showArray();">
</cfform>
</body>
</html>

Thanks,
Neel


Quote:
Originally Posted by mtennor
Shawn,

Have you actually tried to do this because I can not get your suggestion to work? I'm just trying to get to the value a regular variable (not an arrary value) created in the Cold Fusion part of the program by the script part of the program. I've tried this several different ways with no luck. Do you have any idea why this doesn't work?

Thanks,
Mike

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>

<script>
function showArray(){
<cfoutput>
alert('#ab#');
</cfoutput>
}
</script>

</head>
<body>
<cfset ab = 'Goodbye'>
<cfform action="GoNowhere.cfm" method="POST" enablecab="Yes">
<input type="text" name="test" size="5" onChange="showArray();">
</cfform>
</body>
</html>

Reply With Quote
  #5  
Old December 16th, 2004, 04:53 PM
mtennor mtennor is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Maryland
Posts: 3 mtennor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm trying to build a form with two fields. The first field lists peoples' names. The second field is for their email addresses. What I want to happen is that when a name is selected from the first field of names, I want the email address to display automatically in the second field. I need help with the JavaScript function called showEmail(). Please see commented code below.

Thank you for any help you can provide.

Mike

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--- Get the names and email addresses with a query --->
<cfquery name="names" datasource="786_CAmis" dbtype="ODBC">
select distinct TRIM(last_name) + ', ' + TRIM(first_name) as request_by, email_address, record_id
from PhoneDirectory
where category = 'Names'
order by 1
</cfquery>
<!--- Put the email addresses into an array - This seems to be working --->
<cfoutput query="names">
<cfset E[#CurrentRow#] = '#email_address#'>
</cfoutput>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<!--- This function is not working. I'm try to get the selected Index of the name in the
request_by cfselect and use that to put the corresponding email address into the
email_address field. --->
<script language="JavaScript">
function showEmail(){
<cfoutput>
var a = document.TestArray.request_by.selectedIndex;
document.TestArray.email_address.value = E[document.TestArray.request_by.selectedIndex];
</cfoutput>
return true;
}
</script>
</head>
<body>

<cfform action="GoNowhere.cfm" method="post" name="TestArray">
<!--- When the name is selected in this first field I want to put the corresponding
email address in the second field. --->
<cfselect name="request_by"
size="6"
onChange="showEmail();"
query="names"
value="request_by"
display="request_by">
</cfselect>
<p></p>
<cfinput type="Text"
name="email_address"
required="No"
size="50"
maxlength="50">
</cfform>
</body>
</html>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingCold Fusion Development > Access Cold Fusion array values from Javascript


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap