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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CF Query to JS Array forms problem 1

Status
Not open for further replies.

fhilliard

Technical User
Sep 1, 2000
8
CA
I'm loading up a JS Array with a Cold Fusion query and that works fine. However, when I try to get the resulting Java Script array into a form for output it doesn't work. If you can see what's wrong, please email me at frankhilliard@home.com. Here's a URL where you can see what happens:
Here's the code:
<code>
<html>
<head>
<title>Untitled</title>
</head>
<CFQUERY name=&quot;getnames&quot; datasource=&quot;cfug1&quot;>
SELECT id, number, rannumber, visits, password, firstname, lastname, city,
provstate, country, email, organization, clientaddress, clientbrowser, url,
listserv
FROM Members
Order by Lastname
</CFQUERY>
<body>
<br>
<H1>Test area</H1>
<HR>
<cfoutput>
<script language=&quot;JavaScript&quot;>

//store array for addresses
var rec_count = #getnames.recordCount#;
var id = new Array(rec_count);
var number = new Array(rec_count);
var rannumber = new Array(rec_count);
var visits = new Array(rec_count);
var password = new Array(rec_count);
var firstname = new Array(rec_count);
var lastname = new Array(rec_count);
var city = new Array(rec_count);
var provstate = new Array(rec_count);
var country = new Array(rec_count);
var email = new Array(rec_count);
var organization = new Array(rec_count);
var clientaddress = new Array(rec_count);
var clientbrowser = new Array(rec_count);
var url = new Array(rec_count);
var listserv = new Array(rec_count);
<cfset count = 0>
<cfloop query=&quot;getnames&quot;>
number[#count#]= &quot;#number#&quot;;
rannumber[#count#]= &quot;#rannumber#&quot;;
firstname[#count#]= &quot;#firstname#&quot;;
lastname[#count#]= &quot;#lastname#&quot;;
city[#count#]= &quot;#city#&quot;;
provstate[#count#]= &quot;#provstate#&quot;;
country[#count#]= &quot;#country#&quot;;
email[#count#]= &quot;#email#&quot;;
organization[#count#]= &quot;#organization#&quot;;
url[#count#]= &quot;#url#&quot;;

<cfset count = count +1>
</cfloop>
</cfoutput>
//Now the function that is caused by an onchange() from a select box
//JS event:
function changeAddress(obj){
var j = obj.selectedIndex - 1;
with (document.displaymembers){
firstname.value = firstname[j];
lastname.value = lastname[j];
number.value = number[j];
rannumber.value = rannumber[j];
city.value = city[j];
provstate.value = provstate[j];
country.value = country[j];
email.value = email[j];
organization.value = organization[j];
url.value = url[j];
}
}
</script>


<font face-&quot;arial, helvetica&quot; size=&quot;3&quot; color=&quot;navy&quot;>
<form name=&quot;displaymembers&quot;>
<select name=&quot;getnames&quot; onchange=&quot;changeAddress(this)&quot;>
<option value=&quot;&quot;>Personal Addresses
<cfif getnames.recordCount gt 0>
<cfoutput query=&quot;getnames&quot;>
<option value=&quot;#id#&quot;>#lastname#
</cfoutput>
</cfif>
</select>
<br>

<input type=&quot;text&quot; name=&quot;firstname&quot; value=&quot;&quot;>
<input type=&quot;text&quot; name=&quot;lastname&quot; value=&quot;&quot;>
</font>
</form>

</font>
</body>
</html>
</code>
 
Skipping flame, just delete
with (document.displaymembers){
and place in all lines something like following
document.displaymembers.firstname.value = firstname;
(you have name conflict)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top