# Two little textfield related questions

**URL:** <https://forum.kirupa.com/t/two-little-textfield-related-questions/15717>\
**Category:** flash\
**Created:** [March 17, 2003, 2:14pm UTC](https://forum.kirupa.com/t/two-little-textfield-related-questions/15717 "2003-03-17T14:14:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berryblue](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/berryblue/32/182_2.png) [@Berryblue](https://forum.kirupa.com/u/Berryblue)\
**Post date:** [March 17, 2003, 2:14pm UTC](https://forum.kirupa.com/t/two-little-textfield-related-questions/15717/1 "2003-03-17T14:14:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 17, 2003, 2:50pm UTC](https://forum.kirupa.com/t/two-little-textfield-related-questions/15717/2 "2003-03-17T14:50:26Z")

</div>

**Question 1:**  
the attached file should solve the problem 😉

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 17, 2003, 3:38pm UTC](https://forum.kirupa.com/t/two-little-textfield-related-questions/15717/3 "2003-03-17T15:38:08Z")

</div>

could anybody please simplify this mess ? 😛

```auto
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;

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 17, 2003, 7:11pm UTC](https://forum.kirupa.com/t/two-little-textfield-related-questions/15717/4 "2003-03-17T19:11:00Z")

</div>

Thank you very much Kax thats perfect. 🙂

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 17, 2003, 7:18pm UTC](https://forum.kirupa.com/t/two-little-textfield-related-questions/15717/5 "2003-03-17T19:18:09Z")

</div>

well thanks 🙂

i’ll try to clean the code later … 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 17, 2003, 9:19pm UTC](https://forum.kirupa.com/t/two-little-textfield-related-questions/15717/6 "2003-03-17T21:19:28Z")

</div>

> i’ll try to clean the code later … 😉

a promisse kept =)

```auto
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;

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 18, 2003, 8:13am UTC](https://forum.kirupa.com/t/two-little-textfield-related-questions/15717/7 "2003-03-18T08:13:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 18, 2003, 8:37am UTC](https://forum.kirupa.com/t/two-little-textfield-related-questions/15717/8 "2003-03-18T08:37:30Z")

</div>

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