0

Need to capture event after formatting applied on doublebox value.

asked 2009-09-23 13:21:05 +0800

baskaraninfo gravatar image baskaraninfo
536 2 2 9

I need to replicate a value entered in a doublebox to an another doublebox.

zul code:

<window title="Event Demo" border="normal">
	<doublebox id="first" format="###0.0#"
		onBlur="second.value = self.value" />
	<doublebox id="second" />
</window>

If you enter 1.234567 in the first field and press TAB to change focus to the second field.
First doublebox has the value of "1.23". But, the second doublebox has the value of "1.2345".

It seems, the formatted value was not captured in the second doublebox. How can we achieve it?

Thanks.

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2009-09-23 14:53:10 +0800

YamilBracho gravatar image YamilBracho
1722 2

The format property affects as you see in the box so you do not have a format option in your second doublebox so you will see the number as it was entered.
The solution ? Add a format option to your second doublebox:
<doublebox id="second" format="###0.0#" />

link publish delete flag offensive edit

answered 2009-09-24 07:15:54 +0800

baskaraninfo gravatar image baskaraninfo
536 2 2 9

Thank you, YamilBracho :)

Yes, exactly. But, I present this for reproducing the problem. Actually I wanted to capture the value after the formatting applied in the first field.

Check the below code:

<window title="Event Demo" border="normal">
	<doublebox id="first" format="###0.0#"
		onBlur="second.value = self.value" />
	<doublebox id="second" />
	<button label="Save" onClick='alert(first.value)' />
</window>

Type 12.3456 in the first field and click on the Save button. You will get 12.3456 as the first fields value! Eventhough the first field now has only 12.35 as its value.

Hence, I wanted to capture the first fields value after the formatting had been applied. Any suggestion to achieve this?

Thanks.

link publish delete flag offensive edit

answered 2009-09-24 14:28:04 +0800

YamilBracho gravatar image YamilBracho
1722 2

OK. I think you have to use getText() instead getValue(). Say:
<button label="Save" onClick='alert(first.text)' />

link publish delete flag offensive edit

answered 2009-09-25 09:31:15 +0800

baskaraninfo gravatar image baskaraninfo
536 2 2 9

Thank you, YamilBracho :)

first.text did the trick!

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-09-23 13:21:05 +0800

Seen: 163 times

Last updated: Sep 25 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More