Two little textfield related questions

I’m working on a simple flash mx application for a school project and I need a little help. I’m fairly new to flash.

Theres an order form where people can input the quantities they want at the bottom there is a total$ box.

Question 1:
How can I get the total displayed to update as the users change the quantities without having to press any accept buttons?
-Currently total is a dynamic text box and the inputs are input text fields

Question 2:
Is there a way to limit what people can type in an input box? I was hoping to make it so the quantity input boxes would only allow you to type numbers.

Any help would be much appreciated.

Thank you

Question 1:
the attached file should solve the problem :wink:

Question 2:
hmmm … no idea :-
i’ll let know if i think of a solution :slight_smile:

could anybody please simplify this mess ? :stuck_out_tongue:

o = function() {
	for (i=0; i<this.length; i++) {
		this.text.charAt(i) == "0" || this.text.charAt(i) == "1" || this.text.charAt(i) == "2" || this.text.charAt(i) == "3" || this.text.charAt(i) == "4" || this.text.charAt(i) == "5" || this.text.charAt(i) == "6" || this.text.charAt(i) == "7" || this.text.charAt(i) == "8" || this.text.charAt(i) == "9" ? c.text = Number(a.text)+Number(b.text) : this.text = 0;
	}
}
a.text = b.text = c.text = 0;
a.onChanged = this.o;
b.onChanged = this.o;

Thank you very much Kax thats perfect. :slight_smile:

I’ll have to try the code snipit you wrote for the numbers but you really seem to know what your doing :slight_smile:

well thanks :slight_smile:

i’ll try to clean the code later … :wink:

i’ll try to clean the code later … :wink:

a promisse kept =)

o = function() {
	for (i=0; i<this.length; i++) {
		!isNaN(this.text.charAt(i)) ? c.text=Number(a.text)+Number(b.text) : r();
	}
}
r = function() {
	a.text = b.text = c.text = 0;
}
r();
a.onChanged = this.o;
b.onChanged = this.o;

why not just use “restrict”?
as in myTextfield.restrict=“1234567890”;
one line instead of a function… :slight_smile:

why you didn’t say that before!!? :stuck_out_tongue:
ok … sometimes you just overlook the most easiest things :-\