【发布时间】:2012-01-17 10:02:55
【问题描述】:
我正在尝试实现一个 JavaScript 函数,该函数将修改输出到字段中的结果值。
输出到字段的结果示例为 千字节 和英国 磅。
但是,我在表单中包含了按钮,我将使用这些按钮来修改结果以将它们放入
千兆字节、兆字节和便士
请看下面的截图:
伪代码:
>Button pressed calls function.
>Function identifies what button user pressed
>If the button is related to currency unit then modify global variable **currency**
>If the button is related to data units then modify global variable **data**
>Recalculate all fields using new variable values and output to form.
我正在考虑实现它的方式是,我的 JavaScript 中将有两个全局变量,这将根据按下的按钮而改变。然后它们将用于计算数据和金钱。为什么是全球性的? - 我有单独的 JavaScript 函数来检索值并计算它们。
我需要输入有关如何检测按下哪个按钮的信息?
另外,如果你知道任何类似的 JS 示例,那就太好了。
欢迎任何建议!
【问题讨论】:
标签: javascript dom-events currency