coldfusion Form

Posted on 2006-10-24
Last Modified: 2013-12-24

 I have read only access to this database(on a different server) that I am pulling data from via DATASOURCE customer..  I get all the custid in the dropdown on the form but it does not populate customername, etc when custid changes.  

I get the output though when I just do <cfoutput> #customerlist.customerID#,#customerlist.customerName#</cfoutput> etc in the code
however when I do the samething from a local database everything works fine..any ideas?

-------code below

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<cfset DATASOURCE="Customer">
<CFQUERY name="Customerlist" datasource="#DATASOURCE#">
Select * from CustomerTable

<script language="JavaScript" type="text/javascript">
function listItem(custID, custName, custAge, custLoc, custAdd, custCity, custZip, custCntry){

function populateCustInfo(customerID){    
for(x=0; x < arrItems.length; x++){
var arrItems = new Array();
arrItems[arrItems.length]= new listItem('0','','','','','','','');
<cfoutput query="customerList">
arrItems[arrItems.length]= new listItem


<form name="myForm" method ="post" action="customerAction.cfm">
<select name="selCustId" onchange="populateCustInfo(this.value)">
<option value="0">Select</option>
<cfoutput query="customerList">
<option value="#customerId#">#customerName#</option></cfoutput>
  <input type="text" value="" name="txtCustomerName">
<p>  <input type="text" value="" name="txtCustomerAge">
<p>    <input type="text" value="" name="txtCustomerLocation">
<p>  <input type="text" value="" name="txtCustomerAddress">
<p>  <input type="text" value="" name="txtCustomerCity">
<p>  <input type="text" value="" name="txtCustomerZip">
<p>  <input type="text" value="" name="txtCustomerCountry">custcount </p>
<input type="submit" value="submit" name="submit">
<input type="reset" value="reset" name="reset">

Question by:ohemaa
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 36

Accepted Solution

SidFishes earned 500 total points
ID: 17799663
"I get all the custid in the dropdown on the form but it does not populate customername, etc when custid changes.  "

unless you use ajax (or load all of the customer info for every customerid) you can't do this without a trip to the server and back


Author Comment

ID: 17803271
I am not sure how to do this.  can you pls. get me started?
LVL 36

Expert Comment

ID: 17803732
one of the easiest implementations of AJAX is called JSMX found here..

there sample code you can play with...

If that's more than you want to do you can simply do something like this:
have the customer ID select box the only part visible on the page until the customerid is selected and then post the form back to the same page which then shows the full customer detail...

<CFQUERY name="GETCustomerID" datasource="#DATASOURCE#">
Select CustomerID, CustName from CustomerTable

<cfparam name="form.customerid" default ="">
<!--- set this so the page does throw an error when loads with no customerid --->
<form name="myForm" method ="post" action="THISPAGEName.cfm"> <!--- points the post back to this same page --->
<select Name="CustomerID">
<option value="">-- Select Customer --</option>
<cfloop query="CustomerList">
<option value="#GETcustomerID.customerID#">#GETcustomerID.custName#</option>

<input type="submit" Value="Lookup Customer">

<cfif form.CustomerID NEQ ""><!--- then we've selected a customer so show it's info --->

<CFQUERY name="CustomerInfo" datasource="#DATASOURCE#">
Select * from CustomerTable where CustomerID = #form.customerID#

Info for #CustomerInfo.customerID#<br>

  <input type="text" value="#CustomerInfo.custname#" name="txtCustomerName">

<p>  <input type="text" value="#CustomerInfo.custage#" name="txtCustomerAge">

<p>    <input type="text" value="#CustomerInfo.custloc#" name="txtCustomerLocation">
<p>  <input type="text" value=" #CustomerInfo.custaddr#" name="txtCustomerAddress">

<p>  <input type="text" value="#CustomerInfo.custcity" name="txtCustomerCity">
<p>  <input type="text" value="#CustomerInfo.custzip" name="txtCustomerZip">

<p>  <input type="text" value="#CustomerInfo.custcountry#" name="txtCustomerCountry">custcount </p>
<input type="submit" value="submit" name="submit">
<input type="reset" value="reset" name="reset">



Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question