Solved

Auto change the value of the textField when user click add button

Posted on 2003-10-31
1
176 Views
Last Modified: 2010-04-03
I have another problem now. I have a box that displays the total price and total products in the trolley. I want this box update automatically each time user add a product or edit the quantity of the product. I’ve tried loadVariables from asp and displaying all the information. I put it in the movie clip (the box) using onClipEvent(load). When I test it independently, it works well, but when I combine it my flash. it doesn't works. The problem is when user begins to add product in the trolley, the total price & the total quantity is not updated. The value is always 0. Any idea what should I do?

onClipEvent(load)
{
      //Prices = "5,6,7";
      //quantity = "3,1,2";

      loadVariables("addbuy.asp", "", "POST");
      if (Prices eq "") {
            totalItems = "0";
            subtot = "$ " + "0.00";
      } else {
                                Price_array3 = Prices.split(",");
                                Qty_array3 = quantity.split(",");
                                Price_length3 = Price_array3.length;
                                Qty_length3 = Qty_array3.length;

                                for (i=0;i<Price_length3;i++) {
                                                totItem = totItem + parseInt(Qty_Array3[i]);
                                                totPrice = Price_Array3[i] * Qty_Array3[i];
                                                subtotal = subtotal + totPrice;
                                }
                                totalItems = totItem;
                                subtot = "$ " + subtotal;
      }
}
0
Comment
Question by:Cyber_Cus2
1 Comment
 
LVL 27

Accepted Solution

by:
negatyve earned 500 total points
ID: 9657125
onClipEvent (load) {
      //Prices = "5,6,7";
      //quantity = "3,1,2";
      this.loadVariables("addbuy.asp?q=" + (new Date().getTime()), "POST"); // look here
}
onClipEvent (data) {
      if (Prices eq "") {
            totalItems = "0";
            subtot = "$ " + "0.00";
      } else {
            Price_array3 = Prices.split(",");
            Qty_array3 = quantity.split(",");
            Price_length3 = Price_array3.length;
            Qty_length3 = Qty_array3.length;
            for (i = 0; i < Price_length3; i++) {
                  totItem = totItem + parseInt(Qty_Array3[i]);
                  totPrice = Price_Array3[i] * Qty_Array3[i];
                  subtotal = subtotal + totPrice;
            }
            totalItems = totItem;
            subtot = "$ " + subtotal;
      }
}

and when you need to update data, load again the same page in the movieclip, this way:

movieclip_instance_name.loadVariables("addbuy.asp?q=" + (new Date().getTime()), "POST");

if you are loading again from the movieclip itself, use:

this.loadVariables("addbuy.asp?q=" + (new Date().getTime()), "POST");
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

864 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now