• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

500 points depenent list boxes and multiple values can be selected.....

this was orignally asked in coldfusion, but i think i should have asked it in here. moderator, i did not see rules against this, however, if so , i apologize for violating community rules.

here is the question

http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_20542890.html
0
finnstone
Asked:
finnstone
  • 18
  • 17
  • 7
1 Solution
 
henrywwCommented:
ok .. that's quite a lot of reading to do ... from Q_20542890.html  ...

so u have the interface done in flash right?

what version are u using? do u have a link to ur fla? that will help to give u the best solution ...

anyway, i think u have to send a message to the community area or something so to get the pts withdraw from
Q_20542890.html ... rp would know, ... he will be answering this question soon i am sure if it is worth 500pts ... LOL ...

cheers
0
 
henrywwCommented:
i can help u with the lb_one & lb_two selection and assuming that u know how to retrieve them in the cfm file, i don't have coldfusion!!!


so basically u want to join the items selected in lb_one and send the list by a comma delimited string to a cfm file and return a list of correct lb_two ... then send the selected list of lb_one & lb_two to another cfm and get the returned result in a text box ... when u say the "sum" do u mean the return values are numbers and u want the summation?
0
 
henrywwCommented:
hmmmm ... it will certain help if u can give me the files (if any in cfm) or maybe a simple schema of the db u are using. i can setup the links and the table to show u how it can be done with flash and asp, php etc ...

unfortunately i am not an coldfusion expert and none of my servers' got cold fusion on it ...

anyway. i think i understand what u are trying to do .. the sql is quite simple and the flash script is not hard.

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
finnstoneAuthor Commented:
great to hear that you think you can help.. i will award you the 500 points if i can get a total solution...i do not have the flash interface done...

Yes!! you understand. i do not know how to send this info to the database because i am unable to find documentation on manipulating multiple selection. i also do not know how to read multiple values either...i am going to need all the code and explanations, this is going to be a total learning process for me .

SCHEMA
As for your question about thhe sum..this will be a text box that will contain the sum of all the sales for all the lb_one and lb_two selections that were made.

my db looks like this

User  ContactID  Team  PRODUCT  COLOR  SALES

bob    122       hp     labtop   bl     $120,000
bob    122       hp     labtop   gr     $120,000
bob    122       hp     monitor  gr     $96,000
bob    122       hp     monitor  red    $96,000
bob    122       hp     speakers  red   $96,000
bob    122       hp     speakers  red   $96,000


the SALES column will have numbers in it
lb_one selections come from PRODUCT
lb_two selection come from COLOR

in this example if bob had logged in on the login page, and then had chosen labtop and monitor from lb_one and bl and gr from lb_two, then the sum i would want to output in a textbox would be $356,000... this number comes from 120+120+96.!!
*******

the tricky part is that i cannot preprogram all the possible combinations, i want to read it from the database....

help me as far as you can regarding the actionscript, i will hope thats someone can help me with the coldfusion to create the SQL statements necessary.. PLEASE NOTE i already could do the necessary coldfusion if this was a simple select one item from lb_one and lb_two...the fact that i want it to seelct multiple is what is tripping me up!

****
I would also want to show 2 other text boxes...

one would say "this 356,000 is made up of products : labtops,monitors."

the other would say "this 356,000 is made up of colors: bl and gr"
0
 
henrywwCommented:
finnstone,

well, do u have to use cfm? or anything that can achieve the result will do. as mentioned i am not a cfm expert and i don't have a server ready with cfm. if u can do with php or asp then i can give show u how it can be done. is that ok with u?

pick one ... asp or php?

i will post the code the a link for u with the sample data.

oh ... what version of flash are u using? MX? or 5?

cheers
0
 
henrywwCommented:
passing variable to the script to construct an sql to select multiple items from the table is quite easy

1) flash -> send all the select values from lb_one
2) sql = "select ... from ...
where field=value1 or field=value2 or ...
just loop thru the values and construct the appropiate sql

3) if u don't know all the combination, and u need to get all the distinct values ...

just do a select distinct from ... and it will populate the list box with all the distinct values from the table.

anyway ... if it has to be cfm, then i will have to download the trial version for this question :) ...
0
 
henrywwCommented:
ok this is what i've got to show u how the multiple selections with 2 listboxes can be done in flash, extracting data from the two box & find passing data to find the summation....

i made up a very simple (but not normalised) table for u in access 2k cal db1.mdb, the scripting is done in asp instead of cfm. the key in the scripting engine (cfm or asp or php whatever u will be using) is to construct a sql statement to fetch the data from the data passed from flash.

http://www.smartclever.net/example/flash/listboxes/listboxes.zip

extra the file, set it up on ur local computer, allow read/write access for the iurs_MACHINENAME to access the db1.mdb. change the host="http://...... " in the 1st frame of the flash movie, everything will work.

it is that simple.

cheers
0
 
finnstoneAuthor Commented:
henryw, thank you i am digesting it. although cfm is what i will need, let me look at it see if the logic can be transfered into coldfusion.

rob

0
 
finnstoneAuthor Commented:
one other thing, although i need it in cfm and will need more and am far from done or understanding your code , i thank you because your actionscript looks awesome and i am going to study it..

you should know that i will give everyone helps me a nice boatload of points.

0
 
henrywwCommented:
that's ok finnstone, let me know if u have any problem understanding the scripts ...

so can u setup the files on ur computer and run it to see how it works?

it might be a little confusing there like the string contains an extra "," at the end and the result from the asp file as well as in flash when sending ... but the extra "," makes it easy if u are careful enough... when spliting ... so it works even if only 1 item is send like "computer," then the split function works and return 2 values in the array 1 is the computer and 2nd = "" empty string ... otherwise a second routine is needed to check for single item... etc ...


anyway, i haven't done much comment in the action script let me know if u have any problem.

cheers
0
 
finnstoneAuthor Commented:
dont i need asp to test it?
0
 
henrywwCommented:
yes ... are u running on PC?
if so ... what version of windows do u have?
0
 
henrywwCommented:
if not ... let me know i will put it online so u can have a look at it ...
0
 
henrywwCommented:
i have modified the file so it use relative path in the asp and changed the fla/swf ...
u can download from the previous link as given
extra it, put it in ur IIS folder if u are using windows 2000/xp/ i should be very easy, no extra setup is required

u want to see if the asp if working on ur local computer
http://127.0.0.1/where_u_put_ur_files/get_products.asp
should return a list of products

here's the live link to see it working
http://www.smartclever.net/example/flash/listboxes/listbox_multiple.swf

hope this help.

cheers

0
 
finnstoneAuthor Commented:
wow that is so ssweet to see it working. i am going to try and mod it to coldfusion. that is exactly what i wanted to build

first question, what is "any"?

second, let me know if you are trying to implement this in coldfusion...i am also trying to do this so we could work together..
0
 
henrywwCommented:
ar... don't know ... "any" color

not yet, cos i need a server to install cfm ...
so it will take a while

:)
0
 
hartCommented:
<CFCOMPONENT>
     
     <CFFUNCTION name="list_products" returntype="list" hint="Getting the list of products">
          <!--- for now i am harcoding contactid and team to 122 and hp, you can pass these as arguments --->
          <CFSET ContactID = "122">
          <CFSET Team = "hp">
          <CFQUERY NAME="get_products" DATASOURCE="db1" DBTYPE="ODBC">
               SELECT distinct(product) FROM qry_screen_output
               WHERE ContactID = '#ContactId#'
               AND Team = '#Team#'
               Order by PRODUCT
          </CFQUERY>
          <CFSET products = Valuelist(get_products.product)>
          <CFRETURN products>
     </CFFUNCTION>
     
     <CFFUNCTION name="list_colors" returntype="list" hint="Getting the list of colors">
          <CFARGUMENT name="selProduct" type="string" required="true">    
          <CFSET selProduct = ListChangeDelims(selProduct,"','",",")>
          <!--- for now i am harcoding contactid and team to 122 and hp --->
          <CFSET ContactID = "122">
          <CFSET Team = "hp">
          <CFQUERY NAME="get_colors" DATASOURCE="db1" DBTYPE="ODBC">
               SELECT distinct(COLOR) FROM qry_screen_output
               WHERE ContactID = '#Contactid#'
               AND Team = '#Team#'
               AND PRODUCT in (#preservesinglequotes(selProduct)#)
               Order by COLOR
          </CFQUERY>
          <CFSET colors = Valuelist(get_colors.color)>
          <CFRETURN colors>
     </CFFUNCTION>    
     
     <CFFUNCTION name="list_colors" returntype="string" hint="Getting the list of colors">
          <CFARGUMENT name="selProduct" type="string" required="true">    
          <CFARGUMENT name="selColor" type="string" required="true">
          <CFSET selProduct = ListChangeDelims(selProduct,"','",",")>
          <CFSET selColor = ListChangeDelims(selColor,"','",",")>
          <!--- for now i am harcoding contactid and team to 122 and hp --->
          <CFSET ContactID = "122">
          <CFSET Team = "hp">
          <CFQUERY NAME="get_colors" DATASOURCE="db1" DBTYPE="ODBC">
               SELECT sum(sales) sumsales FROM qry_screen_output
               WHERE ContactID = '#Contactid#'
               AND Team = '#Team#'
               AND PRODUCT in (#preservesinglequotes(selProduct)#)
               AND COLOR in (#preservesinglequotes(selColor)#)
          </CFQUERY>
          <CFSET sales = get_colors.sumsales>          
          <CFRETURN sales>
     </CFFUNCTION>    
     
</CFCOMPONENT>

put this code in a file and save it as productdetails.cfc
also change the dsn part of the queries

and go through your help document for using cfc's in flash mx.

i think this should solve your problems
also the rest of the code / logic has to be used from the fla file that was provided to you by the henryww guy.
that is the part of forming the select box data using the array.
0
 
hartCommented:
sorry a small change

<CFCOMPONENT>
     
     <CFFUNCTION name="list_products" returntype="list" hint="Getting the list of products">
          <!--- for now i am harcoding contactid and team to 122 and hp, you can pass these as arguments --->
          <CFSET ContactID = "122">
          <CFSET Team = "hp">
          <CFQUERY NAME="get_products" DATASOURCE="db1" DBTYPE="ODBC">
               SELECT distinct(product) FROM qry_screen_output
               WHERE ContactID = '#ContactId#'
               AND Team = '#Team#'
               Order by PRODUCT
          </CFQUERY>
          <CFSET products = Valuelist(get_products.product)>
          <CFRETURN products>
     </CFFUNCTION>
     
     <CFFUNCTION name="list_colors" returntype="list" hint="Getting the list of colors">
          <CFARGUMENT name="selProduct" type="string" required="true">    
          <CFSET selProduct = ListChangeDelims(selProduct,"','",",")>
          <!--- for now i am harcoding contactid and team to 122 and hp --->
          <CFSET ContactID = "122">
          <CFSET Team = "hp">
          <CFQUERY NAME="get_colors" DATASOURCE="db1" DBTYPE="ODBC">
               SELECT distinct(COLOR) FROM qry_screen_output
               WHERE ContactID = '#Contactid#'
               AND Team = '#Team#'
               AND PRODUCT in (#preservesinglequotes(selProduct)#)
               Order by COLOR
          </CFQUERY>
          <CFSET colors = Valuelist(get_colors.color)>
          <CFRETURN colors>
     </CFFUNCTION>    
     
     <CFFUNCTION name="str_sales" returntype="string" hint="Getting the list of colors">
          <CFARGUMENT name="selProduct" type="string" required="true">    
          <CFARGUMENT name="selColor" type="string" required="true">
          <CFSET selProduct = ListChangeDelims(selProduct,"','",",")>
          <CFSET selColor = ListChangeDelims(selColor,"','",",")>
          <!--- for now i am harcoding contactid and team to 122 and hp --->
          <CFSET ContactID = "122">
          <CFSET Team = "hp">
          <CFQUERY NAME="get_sales" DATASOURCE="db1" DBTYPE="ODBC">
               SELECT sum(sales) as sumsales FROM qry_screen_output
               WHERE ContactID = '#Contactid#'
               AND Team = '#Team#'
               AND PRODUCT in (#preservesinglequotes(selProduct)#)
               AND COLOR in (#preservesinglequotes(selColor)#)
          </CFQUERY>
          <CFSET sales = get_colors.sumsales>          
          <CFRETURN sales>
     </CFFUNCTION>    
     
</CFCOMPONENT>
0
 
hartCommented:
FOR CALLING CFC'S IN FLASH MX U WILL FIND MANY EXAMPLES
hope u will be through with the help of this cfc code
0
 
henrywwCommented:
thanks hart ...  :)
is there any server (free) available we can post the cfm file there for testing.... ??? not likely right ...

so i have to download the trial or something to install on my server to make it work.....
0
 
hartCommented:
see henryww, u need to have flash remoting service and cfmx installed some where to test your code.

And cfmx is not an cheap product, but i think they provide trial software.

i am sorry henryww but i won't be able to help u with this.

because i donot have any free server with cfmx, i have to test it locally and then only i am able to comment :-)

Regards
Harish(Hart)
0
 
henrywwCommented:
that's ok ... thanks hart

i know the remoting part and with asp it is just simple load/send ...

that's why not many of my client willing to pay for cfmx if simple functions like the above mentioned can be done without it. hence, none of my existing server has cf on it.
0
 
finnstoneAuthor Commented:
one other question.. if I wanted to call the ContactID from a CFM page, is all that i need to add to the above code the following:

<CFARGUMENT name="ContactID" type="string" required="true">  

and of course take out your hard coded CFSET values..?
0
 
finnstoneAuthor Commented:
sorry edit to last post

change parts of cfc to:

<CFARGUMENT name="ContactID" type="numeric" required="true">  

....

and change

WHERE ContactID = '#Contactid#'

to

WHERE ContactID = '#ARGUMENTS.Contactid#'

will this work ?
0
 
finnstoneAuthor Commented:
sO Close, I am going to give some bonuses here.!

OK , now the CFM. I would like to reference the ContactID in the CFC. How can i do this. I read that in order to do this I must use CFINVOKE in the cfm... we can call this in CFC using the code above and CFARGUMENT...my question then is how to write CFINVOKE on my logincfm page....?

here is part of my coldfusion code on the login page cfm..

      SELECT ContactID, FirstName, UserRoleName
      FROM Login_table LEFT OUTER JOIN UserRoles
        ON Login_table.UserRoleID = UserRoles.UserRoleID
      WHERE LoginID    = '#Form.UserLogin#'
        AND Password = '#Form.UserPassword#'

So I selected ContactID from the table already, now I must pass it to the CFC ,how do i do that?

What is the specific question...how do i definte the '#Contactid#' in the CFM from the following code in the CFC above? here it is again from the cfc

WHERE ContactID = '#Contactid#'


Here is what I know I have to write...

<CFINVOKE
COMPONENT = "productdetails.cfc"  (this is the cfc)
METHOD = "list_products"   (this is the fuction in cfc)
Contactid = '#form.contactid#' >

Obviously this line needs to be edited because contactid is not a entry on the web page but resides in the database..

Contactid = '#form.contactid#'

How can i change it to reflect the contacid in the database needs to be read from this query on the cfm page (above at beg of post)?
0
 
finnstoneAuthor Commented:
sO Close, I am going to give some bonuses here.!

OK , now the CFM. I would like to reference the ContactID in the CFC. How can i do this. I read that in order to do this I must use CFINVOKE in the cfm... we can call this in CFC using the code above and CFARGUMENT...my question then is how to write CFINVOKE on my logincfm page....?

here is part of my coldfusion code on the login page cfm..

      SELECT ContactID, FirstName, UserRoleName
      FROM Login_table LEFT OUTER JOIN UserRoles
        ON Login_table.UserRoleID = UserRoles.UserRoleID
      WHERE LoginID    = '#Form.UserLogin#'
        AND Password = '#Form.UserPassword#'

So I selected ContactID from the table already, now I must pass it to the CFC ,how do i do that?

What is the specific question...how do i definte the '#Contactid#' in the CFM from the following code in the CFC above? here it is again from the cfc

WHERE ContactID = '#Contactid#'


Here is what I know I have to write...

<CFINVOKE
COMPONENT = "productdetails.cfc"  (this is the cfc)
METHOD = "list_products"   (this is the fuction in cfc)
Contactid = '#form.contactid#' >

Obviously this line needs to be edited because contactid is not a entry on the web page but resides in the database..

Contactid = '#form.contactid#'

How can i change it to reflect the contacid in the database needs to be read from this query on the cfm page (above at beg of post)?
0
 
finnstoneAuthor Commented:
sO Close, I am going to give some bonuses here.!

OK , now the CFM. I would like to reference the ContactID in the CFC. How can i do this. I read that in order to do this I must use CFINVOKE in the cfm... we can call this in CFC using the code above and CFARGUMENT...my question then is how to write CFINVOKE on my logincfm page....?

here is part of my coldfusion code on the login page cfm..

      SELECT ContactID, FirstName, UserRoleName
      FROM Login_table LEFT OUTER JOIN UserRoles
        ON Login_table.UserRoleID = UserRoles.UserRoleID
      WHERE LoginID    = '#Form.UserLogin#'
        AND Password = '#Form.UserPassword#'

So I selected ContactID from the table already, now I must pass it to the CFC ,how do i do that?

What is the specific question...how do i definte the '#Contactid#' in the CFM from the following code in the CFC above? here it is again from the cfc

WHERE ContactID = '#Contactid#'


Here is what I know I have to write...

<CFINVOKE
COMPONENT = "productdetails.cfc"  (this is the cfc)
METHOD = "list_products"   (this is the fuction in cfc)
Contactid = '#form.contactid#' >

Obviously this line needs to be edited because contactid is not a entry on the web page but resides in the database..

Contactid = '#form.contactid#'

How can i change it to reflect the contacid in the database needs to be read from this query on the cfm page (above at beg of post)?
0
 
finnstoneAuthor Commented:
the FLA file was for ASP, can you show me how to edit it for our now newly minted cfc ??

thanks

// change this for the location of ur files
host = "http://127.0.0.1/ofta_qa/db/"

// variable to store selected products & color
var selProduct="";
var selColor="";

db_products = new LoadVars();
db_products.load (host + "get_products.asp");
db_products.onLoad = function () {
     trace("records loaded");
     var prodArray = db_products.products.split(",")
     for (i=1;i<prodArray.length;i++){
          lb_one.addItem(prodArray[i],prodArray[i]);
     }
}

function select_color() {
     var db_color = new LoadVars();
     var selOne = lb_one.getSelectedIndices();
     // nothing selected
     if (selOne.length ==0) return false;
     selProduct = "";
     //construct variable and load data
     for (i=0;i < selOne.length;i++) {
          selProduct += lb_one.getItemAt(selOne[i]).data + ",";
     }
     trace("the select items are : " + selProduct);
     lb_two.removeAll();
     lb_two.addItem("Loading");
     db_color.selProduct = selProduct;
     trace("sending selected products : "  + db_color.toString());
     db_color.sendAndLoad(host + "get_colors.asp",db_color,"POST");
     db_color.onLoad = function () {
          var colArray = db_color.colors.split(",")
          lb_two.removeAll();
          for (i=1;i<colArray.length;i++){
               lb_two.addItem(colArray[i],colArray[i]);
          }
     }
}

function getSum() {
     var db_sum = new LoadVars();
     var selOne = lb_one.getSelectedIndices();
     var selTwo = lb_two.getSelectedIndices();
     if ((selOne.length == 0) || ( selTwo.length == 0) ) return false;    
     
     // products selected
     selProduct = "";
     for (i=0;i < selOne.length;i++) {
          selProduct += lb_one.getItemAt(selOne[i]).data + ",";
     }
     
     // colors selected
     selColor = "";
     for (i=0;i < selTwo.length;i++) {
          selColor += lb_two.getItemAt(selTwo[i]).data + ",";
     }
     
     trace(" sending data to get sales = " + selProduct.toString() +  selColor.toString());
     // send variable
     db_sum.selColor = selColor;
     db_sum.selProduct = selProduct;
     db_sum.sendAndLoad(host + "get_sum.asp",db_sum,"POST");
     db_sum.onLoad = function () {
          // the following code can be replace by the sql statement to do the
          // summation in the get_sum.asp ....
          var sales = db_sum.sales.split(",");
          trace(" sales LOADED ... sum = " + sales.toString());
          if (sales.length == 0) {
               // no sales
               /:sum = 0
          } else {
               /:sum = 0;
               for (i=1;i<sales.length;i++){
                    /:sum += Number(sales[i]);
               }
          }
     }
}

BONUS being posted, more to come after that bonus once evveryinth works.
0
 
henrywwCommented:
well, sorry finnstone ...
i will have no problem if that's to do with flash or any other scripting ... cfm ... i am so in experience in that... i wish i could help.

Hart can u please see what we can do here ..

i can also call in another expert here in the flash area who knows cfm, but i am not sure when he will come ...
0
 
henrywwCommented:
i was refering to the login page, so have u got it sorted out?

for the flash bit, it will take me a while to change the code to cfm for remoting.
0
 
finnstoneAuthor Commented:
i am more confident about solving the login page bit, but hope someone can help me out with that.

as for the asp actionscript being changed to coldfusion friendly, yes i need help with that too.

thanks for everyones help so far, i think ive got 1500 points out there now, but i will increase that amount.
hope people see this as a learning experience as well, especially those who are learning new languages/platforms to help me out, thanks.
0
 
hartCommented:
finstone your problems are over i have successfully interacted cfc's with cfmx:-)

i hope you already have the required remoting components installed

i cannot upload these anywhere so i am going to paste the codes. ok or give me your mail address and i will amil it to you.

firstly the fla file code
---------------------------selectboxes.fla----------------
//change http://192.168.3.25/ to your cfmx server ip address

//also changee harish.listboxes.productdetails to your program root directory /subdirectory if any/name of the cfc

//u need the remoting components for these
#include "NetServices.as"
#include "NetDebug.as"

NetServices.setDefaultGatewayUrl("http://192.168.3.25/flashservices/gateway");
var gw = NetServices.createGatewayConnection();
var products = gw.getService("harish.listboxes.productdetails", new get_products());
products.list_products();

function get_products()
{
      //receives data returned from the method
      this.onResult = function(result)
      {
            
            var prodArray = result.split(",");
            for (i=0; i<prodArray.length; i++)
            {
                  lb_one.addItem(prodArray[i], prodArray[i]);
            }            
            
      }

      this.onStatus = function(error)
      {
            trace("Error : " + error.description);
      }
}
function get_colors()
{
      var selOne = lb_one.getSelectedIndices();
      if (selOne.length == 0)
      {
            /:sum = "$0";
            return false;
      }
      selProduct = "";
      for (i=0; i<selOne.length; i++)
      {
            if (selProduct=='')
            {
            selProduct = lb_one.getItemAt(selOne[i]).data;
            }
            else
            {
                  selProduct += ","+lb_one.getItemAt(selOne[i]).data;
            }
      }
      lb_two.removeAll();
      lb_two.addItem("Loading");
      if (selProduct != '')
      {
            var colors = gw.getService("harish.listboxes.productdetails", this);
            colors.list_colors(selProduct);
            this.onResult = function(result)
            {            
                  var colorArray = result.split(",");
                  lb_two.removeAll();
                  for (i=0; i<colorArray.length; i++)
                  {
                        lb_two.addItem(colorArray[i], colorArray[i]);
                  }            
            }

            this.onStatus = function(error)
            {
                  trace("Error : " + error.description);
            }
      }
      else
      {
            lb_two.removeAll();
            /:sum = "$0";
      }
      
}
function get_Sum() {
      var selOne = lb_one.getSelectedIndices();
      var selTwo = lb_two.getSelectedIndices();
      if ((selOne.length == 0) || ( selTwo.length == 0) ) return false;      
      
      // products selected
      selProduct = "";
      for (i=0; i<selOne.length; i++)
      {
            if (selProduct=='')
            {
                  selProduct = lb_one.getItemAt(selOne[i]).data;
            }
            else
            {
                  selProduct += ","+lb_one.getItemAt(selOne[i]).data;
            }
      }
      
      // colors selected
      selColor = "";
      for (i=0; i<selTwo.length; i++)
      {
            if (selColor=='')
            {
                  selColor = lb_two.getItemAt(selTwo[i]).data;
            }
            else
            {
                  selColor += ","+lb_two.getItemAt(selTwo[i]).data;
            }
      }      
      if ((selProduct != '') && (selColor != ''))
      {
            var sumsales = gw.getService("harish.listboxes.productdetails", this);
            sumsales.str_sales(selProduct,selColor);
            this.onResult = function(result)
            {            
                  /:sum = "$" + result;
            }

            this.onStatus = function(error)
            {
                  trace("Error : " + error.description);
            }
      }
      else
      {
                  /:sum = "$0";
      }
}

//bonus for u all the required checks have been done to avoid errors
--------------------------------------------------------

Now the code of the cfc file that is productdetails.cfc
--------------------------- productdetails.cfc ----------

<!--- Harish Nair --->
<CFCOMPONENT>
      
      <CFFUNCTION access="remote" name="list_products" returntype="string" hint="Getting the list of products">
            <!--- for now i am harcoding contactid and team to 122 and hp, you can pass these as arguments --->
            <CFSET ContactID = "122">
            <CFSET Team = "hp">
            <CFQUERY NAME="get_products" DATASOURCE="db1" DBTYPE="ODBC">
                  SELECT distinct(product) FROM qry_screen_output
                  WHERE ContactID = '#ContactId#'
                  AND Team = '#Team#'
                  Order by PRODUCT
            </CFQUERY>
            <CFSET products = Valuelist(get_products.product)>
            <CFRETURN products>
      </CFFUNCTION>
      
      <CFFUNCTION access="remote" name="list_colors" returntype="string" hint="Getting the list of colors">
            <CFARGUMENT name="selProduct" type="string" required="true">      
            <CFSET selProduct = ListQualify(selProduct,"'",",")>
            <!--- for now i am harcoding contactid and team to 122 and hp --->
            <CFSET ContactID = "122">
            <CFSET Team = "hp">
            <CFQUERY NAME="get_colors" DATASOURCE="db1" DBTYPE="ODBC">
                  SELECT distinct(COLOR) FROM qry_screen_output
                  WHERE ContactID = '#Contactid#'
                  AND Team = '#Team#'
                  AND PRODUCT in (#PreserveSingleQuotes(selProduct)#)
                  Order by COLOR
            </CFQUERY>
            <CFSET colors = Valuelist(get_colors.color)>
            <CFRETURN colors>
      </CFFUNCTION>      
      
      <CFFUNCTION access="remote" name="str_sales" returntype="string" hint="Getting the list of colors">
            <CFARGUMENT name="selProduct" type="string" required="true">      
            <CFARGUMENT name="selColor" type="string" required="true">
            <CFSET selProduct = ListQualify(selProduct,"'",",")>
            <CFSET selColor = ListQualify(selColor,"'",",")>
            <!--- for now i am harcoding contactid and team to 122 and hp --->
            <CFSET ContactID = "122">
            <CFSET Team = "hp">
            <CFQUERY NAME="get_sales" DATASOURCE="db1" DBTYPE="ODBC">
                  SELECT sum(sales) as sumsales FROM qry_screen_output
                  WHERE ContactID = '#Contactid#'
                  AND Team = '#Team#'
                  AND PRODUCT in (#preservesinglequotes(selProduct)#)
                  AND COLOR in (#preservesinglequotes(selColor)#)
            </CFQUERY>
            <CFSET sales = get_sales.sumsales>            
            <CFRETURN sales>
      </CFFUNCTION>      
      
</CFCOMPONENT>

---------------- end of code for cfc file----------------

save both of this in the same folder and just enjoy..

i hope you will award the points soon, just kidding :-)

Regards
Hart(Harish)




0
 
hartCommented:
also if u are awarding then kindly award in coldfusion question because i am a cf developer and i wouldn't want to have points in the flash section.

hope u understand :-)

Regards
Hart(Harish)

0
 
henrywwCommented:
that's great ...

i am still trying to get the cfmx on my localhost to work.... (learning ....!)

i think finnstone will be very happy now, ...

thanks Harts
0
 
finnstoneAuthor Commented:
Hart, you treat me too well. Wow, this actionscript is sweet, i am currently digesting .. I am very impressed, did you even have experience in actionscript before, or javascript. pretty cool man.

As for the points, I will see how I can tranfer these questions onto the coldfusion page and award you most of them. henryw, i will also give you a good amount too. there is a post on the coldfusion page that i can give you a good portion of the 1000 there already, i will see about moving some of this 500 too.

One more question, this was my previous one about not hardcoding the team and contact id but pulling it from the database after the login...I am confident you can easily solve this because it is a coldfusion question , ok here goes

previous post
***************

sO Close, I am going to give some bonuses here.!

(1)
OK , now the CFM. I would like to reference the ContactID in the CFC. How can i do this. I read that in order to do this I must use CFINVOKE in the cfm... we can call this in CFC using the code above and CFARGUMENT...my question then is how to write CFINVOKE on my logincfm page....?

here is part of my coldfusion code on the login page cfm..

     SELECT ContactID, FirstName, UserRoleName
     FROM Login_table LEFT OUTER JOIN UserRoles
       ON Login_table.UserRoleID = UserRoles.UserRoleID
     WHERE LoginID    = '#Form.UserLogin#'
       AND Password = '#Form.UserPassword#'

So I selected ContactID from the table already, now I must pass it to the CFC ,how do i do that?

What is the specific question...how do i definte the '#Contactid#' in the CFM from the following code in the CFC above? here it is again from the cfc

WHERE ContactID = '#Contactid#'


Here is what I know I have to write...

<CFINVOKE
COMPONENT = "productdetails.cfc"  (this is the cfc)
METHOD = "list_products"   (this is the fuction in cfc)
Contactid = '#form.contactid#' >

Obviously this line needs to be edited because contactid is not a entry on the web page but resides in the database..

Contactid = '#form.contactid#'

How can i change it to reflect the contacid in the database needs to be read from this query on the cfm page (above at beg of post)?


(2)Also where should i put these CFINVOKES in, which CFM page, my forceuserlogincfm page which is included by application in every page, or do i put it in my userlogincfm page?
0
 
finnstoneAuthor Commented:
in order to accomodate not hard coding the team and contact id, we now have to set up CFARGUMENTS for these variables in the CFC file!. i also need your help with this as well...like you havent given me enough already, when this is working i will defintiely show my gratitude man, this has been great.

please refer to my previous post for this, but basically is the following all i need to add to the CFC file, for EACH cfunction???

<CFARGUMENT name="contactid" type="numeric" required="true">  
<CFARGUMENT name="team" type="string" required="true">      

and change the where clauses of each function to

Where ContactID = '#Contactid#'
Where Team = '#Team#'

Is this right HART???
0
 
finnstoneAuthor Commented:
my email is tob_baker@yahoo.com, definitely send me the files so i can take a look at it all. thanks
0
 
finnstoneAuthor Commented:
OR... should i do this. instead of using CFINVOKE in the CFM and using CFARGUMENT in the CFC.. i can already used the pre establised variables from my login pages.. (if this is confusing send me an email and i will send you my login cfm)

But basically contactid was defined in my login cfm by the following CFLOGIN NAME CODE and then reference this by using CFSET ContactID = Getauthuser()

   <CFQUERY NAME="GetUser" DATASOURCE="#DataSource#">
      SELECT ContactID, FirstName, UserRoleName
      FROM Contacts LEFT OUTER JOIN UserRoles
        ON Contacts.UserRoleID = UserRoles.UserRoleID
      WHERE UserLogin    = '#Form.UserLogin#'
        AND UserPassword = '#Form.UserPassword#'
    </CFQUERY>
   
    <!--- If the username and password are correct... --->
    <CFIF GetUser.RecordCount EQ 1>
      <!--- Tell ColdFusion to consider the user "logged in" --->
      <!--- For the NAME attribute, we will provide the user's --->
      <!--- ContactID number and first name, separated by commas --->
      <!--- Later, we can access the NAME value via GetAuthUser() --->
      <CFLOGINUSER
        NAME="#GetUser.ContactID#,#GetUser.FirstName#"
        PASSWORD="#FORM.UserPassword#"
        ROLES="#GetUser.UserRoleName#">  

***************

So now i can call contactid by using this in my cfc file..

<CFSET ContactID = ListFirst (GetAuthUser () ) >

i could do something similar for the team variable as well.... help guys!!

Hart definnitely send me that flash, is it all in frame 1? what are the instance names of the boxes, etc, thanks.
0
 
henrywwCommented:
ok i have done my part and i think hart can take over the rest from here :)

thanks guys. & cheers
0
 
hartCommented:
I only knew CFMX & javascript, i had no idea about flash, but because beacuse of ur question i got a chance to research on it. thanx anywayz :-)

see u already have solution for your problems
try
<CFSET ContactID = ListFirst (GetAuthUser () ) >
directly inside the functions and see if it works out.

If it doesn't then let me know
and i will send you the files go through and i think u will get your solutions if u go through peoprely.

The mail will have the subject as your files
i am sending u the cfc and the fla

Regards
Hart(Harish)




0
 
henrywwCommented:
well ... this question is cross bewteen CF & Flash ...

and me too, now i have chance to look at the CFMX and see if that could be a solution to some of my clients ... but then again the cost is really too high for a simple question like this ... i am sure there are much more powerful function in cfmx, but most functions can be somehow implemented using php or asp ... so ...

a good learning process for all of us i suppose.

thanks hart :)
0
 
finnstoneAuthor Commented:
aMAZing, hart learned stuff he had never done before and was able to help me in a quick time period.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 18
  • 17
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now