1 Reply Latest reply on Mar 13, 2007 6:55 AM by insuractive

    onchage script with cfselect

      I need an example of the following:
      I have cfselect on the form that has display set to CompanyName and value set to CompanyID.
      There is also cfinput for CompanyAddress on the same form.
      When user selects a list item in cfselect, I need to take CompanyID, lookup CompanyAddress in the database, and populate cfinput with CompanyAddress.
      Please Help!!!
      Thanks, Sergey
        • 1. Re: onchage script with cfselect
          insuractive Level 3
          There are a few of ways you can accomplish this - all with differing levels of security and complexity.

          1) You can include the company addresses is your Query, then use coldfusion to create a javascript variable (e.g. #companyID#_address) for each address. Then when a user selects the company from the drop down box, have a javascript funtion set the value of CompanyAddress:
          document.form.CompanyAddress.value = Eval(this.value + '_address');
          There are obvious security problems with this approach as every company's address will be listed on in your HTML code

          2) You can use AJAX to retrieve the information "behind the scenes". This is one of those situations that ajax is perfect for - the only problem is the complexity of the operation if you are not familiar with the methodology.

          3) If you are familiar with using WDDX (a generic XML standard), you can convert your ColdFusion query to a javascript WDDX package using <cfwddx>. Personally, I don't have much experience working with WDDX in javascript, but I'm pretty sure you could use the companyID as a key to retrieve your company address data