Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » How to compute "a * b = c"? (Apex 3.2.1, Oracle 10g XE, MS Windows XP SP3, IE7)
How to compute "a * b = c"? [message #459573] |
Mon, 07 June 2010 03:43 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
I have recently installed Apex 3.2.1, imported an Excel table and Wizard created a sample application which I'm now trying to "improve". Obviously, I'm not very good at it.
On the other hand, I know Oracle Forms. I'm not sure this is an advantage, because certain features are much different from what I'm accustomed to.
Most probably solution of my problem is very simple. This is what I'd like to do: compute "a * b" and put it into "c".
For an illustration, perhaps it is better to post a screenshot of what I have: this is a form (called from an interactive report), that can be used both for modifying existing records, as well as inserting new ones. This is how it looks like in "update" mode:
As you can see, "Litara * Cijena = Iznos". No problem about it - I created a computation:
- Type = SQL Query
- Computation point = Before Region(s)
- Source (Computation) = select round(:p22_cijena * :p22_litara, 2) from dual
Now, the same form in "insert" mode (which troubles me):
I'd like the form to "automatically" compute "10 * 5" and put the result into the "iznos" item. But, I don't know how to do that.
Reading the documentation and googling for the solution (I read quite a few OTN Apex Forum discussions), I found out (perhaps I'm wrong, I don't know) that JavaScript is what I need. Unfortunately, I know less than zero about it.
This is the OTN Apex Forum topic I found interesting, so I tried to simulate what they have done.
This is my attempt:- In page (it is page 22) HTML Header I wrote this "script" (most probably wrong, but I don't know better):
<script language="JavaScript">
function izracunaj_iznos()
(
$x('P22_IZNOS').value == $x('P22_LITARA').value * $x('P22_CIJENA').value
)
</script>
- In P22_CIJENA's "Element" section, I put
onblur="izracunaj_iznos()" into the "HTML Form Element Attributes" field.
Why did I do that? Because I found that someone managed to - using the following script<script type="text/javascript">
function test(){
window.alert('This is a test.');
}
</script>
along with display a message on the screen.
Yes, I know - I don't want a message. But, once again, I'm an absolute beginner in that. I checked list of HTML Events and tried a few more but - no success either.
The result (after leaving the "cijena" field is message at the bottom of my Internet Explorer 7 window.
I also tried some more options, such as changing "Iznos" field's "Source" properties to "SQL Query", "PL/SQL function body" and similar, but - no success either.
I'm afraid I'm out of ideas.
Could someone, please, point me into the right direction? What should I read (hopefully, not the whole Java Scripting and HTML documentation).
Is there an "easy" way to do such a trivial thing as "a * b = c"?
-
Attachment: g_01.PNG
(Size: 7.09KB, Downloaded 3656 times)
-
Attachment: g_02.PNG
(Size: 5.87KB, Downloaded 3674 times)
-
Attachment: g_03.PNG
(Size: 0.99KB, Downloaded 3614 times)
|
|
|
|
|
|
|
Re: How to compute "a * b = c"? [message #459704 is a reply to message #459691] |
Tue, 08 June 2010 01:38 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
So I compared your solution with my attempt. Basically, I was on the right track, with two "minor" (right ...) modifications:
- it is not "==" but "="
- I shouldn't have used "()" brackets, but "{}" ones
It means that the following script does the job as well:
HTML (Page) Header:
<script language="JavaScript">
function izracunaj_iznos()
{
$x('P22_IZNOS').value = $x('P22_LITARA').value * $x('P22_CIJENA').value;
}
</script>
P22_CIJENA HTML Form Element Attributes:onblur="izracunaj_iznos();"
Thank you once again; it is an unpleasant role while one acts as a newbie.
I have found an online tutorial and now I'm doing some reading on JavaScripting. Hopefully, I'll be a little bit smarter till the end of the day.
Heh, blindman. Now I payed more attention to a "This is a test" script I posted in my first message. There are too {} brackets there (instead of () ones). Gee, I should have opened both eyes ... what an idiot.
[Updated on: Tue, 08 June 2010 01:41] Report message to a moderator
|
|
|
|
Re: How to compute "a * b = c"? [message #461624 is a reply to message #459573] |
Sun, 20 June 2010 01:18 |
BBMamun
Messages: 94 Registered: February 2010 Location: Dhaka, Bangladesh
|
Member |
|
|
Thanks for your beautiful illustration. You have gone a long way with the problem. I believe you want to populate the column C as we forms developers use to do..that is by using a process similar to POST-CHANGE trigger in Forms developer. To do that in Oracle Apex javascript is the solution. And al long as I have seen your javascript code it seems ok(I am also a novice in javascript). The message that you get in IE7, I think it is browser security property that prevents running the javascript. Try changing the browser setting and u can test in mozilla firefox/opera.
Regards
Hasan Al Mamun
Programmer
Bangladesh Bank
Bangladesh
[Updated on: Sun, 20 June 2010 01:18] Report message to a moderator
|
|
|
|
Re: How to compute "a * b = c"? [message #461660 is a reply to message #461649] |
Sun, 20 June 2010 12:05 |
BBMamun
Messages: 94 Registered: February 2010 Location: Dhaka, Bangladesh
|
Member |
|
|
Thanks for notifying. I have presumed that the javascript written is syntactically correct. So I did not actually look for the javascript syntax. You have rightly pointed out the errors and solved it. Thanks for that.
Regards
Hasan Al Mamun
|
|
|
Goto Forum:
Current Time: Wed Jan 22 06:24:00 CST 2025
|