Calculate values of element in JavaScript
Hi all
I need to do some calculations on a page and my users want to see the result immediately, so I can't do it with PS/SQL. Suppose I just need to summarize the two values of element (PX_1 + PX_2) and assign the result to the third (PX_3). So the procedure could be something like create a dynamic JS action that affects the item PX_3, JS code would be something like:
parseFloat ($v ('PX_1')) + parseFload ($v ('PX_2'))
So far so good, but unfortunately in my national settings, we have the space as a thousands separator and comma as a decimal character and I have to perform a more complex calculation with more than two elements. The question is whether there is something more simple and user-friendly that do the hard (e.g. to take all the field values = > remove the spaces = > replace "decimal points" with decimals = > calculations = > format the result according to our locale).
There may be a few jQuery or the API functions that can do the job for me and I am not aware. As there is a lot of "online calculations" in my application, any help will be much appreciated.
Kind regards
Pavel
Guys,
Thank you all for your answers. Seems like it accounting.js: JavaScript number and put currency in the form of library can do any number of formatting and conversions I need.
Best regards
Pavel
Tags: Database
Similar Questions
-
Development of the element using Javascript
Hello experts!
I have a problem with the setting of a value of element using javascript.
I have a button on my page which should regulate my point P1_SORT to the value 'test '.
I call the function with the following statement in the section my button URL:
The problem is that the item is not defined when you call the function.javascript:f_setItem('P1_SORT');
Maybe you can help me understand why the service is defective and how it should be like.
The code I have (in my head of page) is as follows:
Thanks for your help!<script language="JavaScript" type="text/javascript"> function f_setItem (P1_SORT) { get.add(P1_SORT,('test').value) gReturn = get.get(); get = null; ; } </script>
Sebastian'test' is a string? or the element name?
Try this:
function f_setItem (P1_SQRT) { var pValue='test'; $x(P1_SQRT).value = pValue; }
or
function f_setItem (P1_SQRT) { var pValue='test'; $x('P1_SQRT').value = pValue; }
but of course it is jquery
Edit: second work because the element name is P1_SQRT -, as a variable in the function definition. If U accept jquery U should combinate with this example and I think it should work fine
Edit2: Var initialized U get?
-
Can a dynamic action of type 'alert' display a value of field without javascript?
Hello
can a dynamic action of type 'alert' display a value of field without javascript ( alert ( $x (P '200_OP').value)); ?
What should I write in the 'text' section to display in the alert, the value of P200_OP for example?
Gianpaolo cordially
Hi gianpagi,
gianpagi wrote:
I know that with "run JavaScript Code" works. My question is about action as 'alert '.
Dynamic action "Alert" is expected to this only the string to display in the alert. May not be able to access the current value set in a page element.
Therefore, "Run the Code JavaScript" only works in this case where your can integrate the current values of the DOM html elements
If you notice that da 'Alert' request 'Text' and 'Execute JavaScript Code' DA 'Code' request to be executed.
Kind regards
Kiran
-
return two values of columns via Javascript
For the same purpose as:
OnClick = "$s ('P1_DEPTNO', #DEPTNO #); return false; »
to return a value from column via javascript, is it possible to return 2 values? Example:
OnClick = "$s ('P1_DEPTNO', #DEPTNO #); $s ('P1_EMP, #EMPLOYEE #); return false; »
Thank you all :)
MaxMaxime Carrier wrote:
Sorry for the wrong question form, I'm not an English speaker, so I try my best to make sentences clear.My goal is like this in this issue: Insert the value of a column in the report in a page with JavaScript element - 2?
My Apex version is: 4.0.2.00.06
My DB is: Oracle 11G
My browser: IE 7I'm trying to save two values when I click on a link in a report. I will use these values in which the declaration of another report. The content of the second report will depend on the link I clicked in the 1st. It will change dynamically without reloading the entire page.
Standard or interactive report?
Where is the defined link? Column link IR? The column link? HTML embedded in the report query?
One of the two values is not a number.
Use quotes around chains of substitution of the column as shown above.
-
Get a value of element of cluster a variant
Hello
I'm trying to get a group of its variant element value
If I look at the alternative indicator, the elements and their values are displayed. However, after getting Cluster Information.vi, which I expect to break up the cluster in its different elements, all I get is the type information, not the value of the element. In other words, looking at the table of elements, all that appears are 0, I expected values and element names.
So my question is, how do I cluster of values of the element?
Thank you
One of my hobbies is flattened function variant String provides the rest string, but it can be worked around with a bit of ugliness.
-
How to make a presentation tabular readonly based on a value of element
Hello world
I'm getting there, but I need to make a tabular presentation read-only based on a value of element.
I copied it somewhere (thank you) and changed to my needs and it works very well set the second column in my form
read-only.
Just need to set the selector jQuery jQuery ("td [headers = 'PRODUCT_NAME']"), cos that's my name of the column.var els = jQuery('#Entry_Form input[name="f02"]'); /*var r = confirm("els is " + els);*/ els = els.filter(function(index){ return jQuery(this).val() != ""; });
you will also need to give a static id of the registration form to the form.
I'll try to understand what this code means exactly one of these days, but now I need to do
the entire shape in a read-only table based on a text element: P5_CONTROL.
Grateful for any help on this matter, in the format above, if possible. Greek to me but compact and it works.
Kind regards.
LeckrajHello
in fact, it has no code, just a dynamic action. You may need to change the event that triggers the it.Event: change
Selection type: Elements (s)
Product (s): P1_ED
Condition: equals
Value: DReal Action 1
Action: disable
Fire when the Page loads: Yes
Selection type: jQuery Selector
jQuery Selector: entry [id ^ = 'f']Real Action 2
Action: disable
Fire when the Page loads: Yes
Selection type: jQuery Selector
jQuery Selector: entry [id = "check-all-rows"]False Action 1
Action: activate
Fire when the Page loads: Yes
Selection type: jQuery Selector
jQuery Selector: entry [id ^ = 'f']False Action 2
Action: activate
Fire when the Page loads: Yes
Selection type: jQuery Selector
jQuery Selector: entry [id = "check-all-rows"]Best regards, Garry
-
change the values of 'choiseListe' with javascript
Dear Sir
Is it possible to change the values of 'choiseListe' with javascript.
Example they have a choseListe:
Country / / / values
United States us
France fr
Sp Spain
When he clicks in a botton I whant to change this choceListe:
Country / / / values
My Morocco
PT Portugal
............
Thank you
Hello
Drop-down lists and drop-down menus can be scripted against without much to safely.
You would need something like that in the click event of the button:
listbox1.rawValue = null; //clear previous choice listbox1.clearItems(); //clear the list items listbox1.addItem("Moocco", "ma"); //add new list items listbox1.additem("Portugal", "pt");
Hope that helps,
Niall
-
How to get the value of the global element using javascript or ajax!
Hello!
How can I read at global(point application created in the shared components) using ajax or javascript?
You can imagine that I need to get the value of this element by function as:
-----
Function getText() {var itemVal = $x ('MY_GLOBAL_ITEM') .value;} Return itemVal; }
-----
.. .but I can't do it because it is not made to couse of the page it is global element! so, anyone know no work around to do?
I know that I can make point page and read the value of that, but not what I really need!
If I have 100 pages and all pages need to use my function, it would take 100 Articles :) - that's why its no good average!
Please, share your ideas!
THXRafix,
You must use a little AJAX to retrieve a request element value. Three steps in this solution. Implementation of a callable JavaScript function, creating an application process on the request and call the JavaScript function with dynamic action.
1 set up a JavaScript function that can be called by:
This function calls the process of application level which has a visibility of the element of your application and then returns the value of points.
Edit your page and JavaScript code according to the code in the 'function and Variable global statement' of your page. You can also add to the model page, that you use, but you also have to encapsulate this code in the script tags.
getAppItem = function(pItemName){ var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=GET_APP_ITEM',$v('pStepId')); get.addParam('x01',pItemName); gReturn = get.get(); get = null; return gReturn; }
2. creating an application on request process:
The application of level process has visibility to your application-level element. It is to retrieve the value of points and it prints the htp buffer. Essentially, this acts as a way to return the values of AJAX calls (the javascript function we set previously);
go to the shared components > procedures > Create.
Point process: "We Demand: run this application...". »
Name: GET_APP_ITEM
Type: Anonymous PL/SQL blockdeclare -- get the item name passed into the JavaScript function. app_item_name varchar2(30) := apex_application.g_x01; begin -- print its value to the buffer htp.p(v(app_item_name)); end;
3. call the JavaScript function with dynamic action:
The function call allows to specify an application-level element name and have its returned value. The trigger event is specific to what you need, but the action must be of type to run JavaScript code. In my case immediately the value of P1_NUMBER to my value of demand points. This code doesn't have to be in a dynamic action, but it helps to stay organized. you could call it from any script tag.
$s('P1_NUMBER',getAppItem('MY_APP_ITEM'));
See you soon,.
Janet Tyson -
.. .page is submitted.
Friends,
I have my page apex in the attribute of the HTML Body with some Javascript functions I wrote to determine the following:
< pre > onLoad = "RadioGroupEnableDisable ('P213_COMPLETED', true); disableStartEndDate(); "< / pre >
These disable a group of radio buttons and two text fields and work as expected, the values in the controls, I can't change the values and the values are changed properly when I navigate to the next record.
However
When I try to edit a field that allow entry and try to save the changes when the page is submitted, I have an error message stating that the required fields are null (these are the same fields that I disabled).
Is this expected behavior? or I'm doing something very wrong?
Any help will be very appreciated!Hello
Disabled items are not submitted. It's standard HTML.
What is your problemBR, Jari
-
Changing a value of the element in Javascript
Hello
I have this code that returns a string in gReturn.
I want to store this value in diversity - which is a display only text box.
Were not able to make it work, any ideas?
Concerningfunction Get_Dealer(pThis,oThis){ var get = new htmldb_Get(null,html_GetElement('pFlowId').value, 'APPLICATION_PROCESS=Get_Dealer_Status',0); get.add('TEMPORARY_ITEM',pThis.value); gReturn = get.get(); get = null; document.getElementById(oThis).element.value = gReturn; }
AdamUse this:
function Get_Dealer(pThis,oThis){ var get = new htmldb_Get(null,html_GetElement('pFlowId').value, 'APPLICATION_PROCESS=Get_Dealer_Status',0); get.add('TEMPORARY_ITEM',pThis.value); gReturn = get.get(); get = null; $s(oThis.id, gReturn); }
-
APEX submit changes to the database when the value is changed in Javascript?
Hello
IM new at the Apex and use v4.1.
What I want to do, is to have a tabular presentation that will have 5 fields and a number of fields only reading based on a SQL table & reviews, when a user updates one of the 5 fields entry I want to save the change to the databases automatically.
I thought that this could be done using Ajax and Javascript, but my knowledge is not at a high enough level to make it work.
I think what I need to do:
1 create an AJAX callback process (say its called "Submit Changes") - it comes to PL SQL that will update the database based on the value of the field that was changed. I think that this will require the number of line in table form to pass in.
2. create a header HTML with Javascript code that calls the recall AJAX process - I found the below on the net, but do not think that I changed it correctly:
< script type = "text/javascript" >
function Submit_Value() {}
var ajaxRequest = new htmldb_Get (null, & APP_ID., 'APPLICATION_PROCESS is Submit Changes', 0);
var ajaxResult = ajaxRequest.get ();
Alert (ajaxResult);
}
< /script >
3. change the attributes of elements ' "on the column compared to something like onchange ="Submit_Value () ";
So far I have not been able to get this working and would be grateful for any help or suggestion.
Thank you
Goesjust a quick thought: I myself remember in 3.x days by using a process with a space name did not work (at least when I was trying to use), I have always since then named such with underscores in the... IE: submit_changes the two (the name of the process in the apex) and the reference of the code in javascript
-
Dynamic alignment of the value of element column and report page
Hi friends,
I have an interactive report that contains the columns as
< li > empno
< li > name
In the light of the foregoing, I 'empno' with an alignment of the left column and a 'name' with an alignment of the left column.
It is possible to substitute the alignment of the data that we put into the report according to the value of the application as element
If my application point is about US, so I need the alignment of the column 'empno' and 'Name' to the left, and if the value of point of my app's AR, I need the alignment of the column 'empno' and 'Name' to be right. What is possible to achieve dynamic alignment for the report data to two columns 'empno' and 'Name', according to the value of application page element.
And also, in the case of the page element, I have a page element with a name of P1_NAME in which he has an alignment of the Horizontal/Vertical element on the left.
I need to this alignment of the element of the page element behave dynamically according to the order of the day of the application page, as if the order of the day of the application page called WE then the alignment of the element of the page item must be left and if the order of the day of the application page called AR and then the alignment of the element of the page element has to be right.
Is it possible to make some friends of my scenario two above. Kindly help me with this.
Thanks in advance.
Brgds,
MiniHey Mini,
To change the alignment on the fly, you need a change in your IR and javascript.
First change the columns that you want to change the alignment for. Add the following code in The HTML Expression in the column formatting part. (Detail of the column)
#HERE _THE_COLUMN_NAME#
Then you can change the easy alignment for these areas with the following code
$(".align_style").css("text-align","left")
This can be in a DA, or just on the loading of the page.
Kind regards
Kees Vlek
-----
Company: http://www.orcado.nl
Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
Twitter: http://www.twitter.com/skier66
If the answer to question please change replied and mark the appropriate post as correct / helpful.Published by: kvlek on 7-mei-2013 14:47
-
Passing a value of element from an embedded with $a_report report
Hello
One more question for the end of this year...
APEX: 3.2.1 + earphone of apex
OS: Linux
I have an interactive report. When I select a line get an id that defines a P83_ID_OPERATION element in a javascript script.
function table_object(pId){ this.id = pId; this.start_record = 1; //optional this.num_record = 5; //optional this.interval = false; this.refresh = function(pTime){ if(my_report.interval){clearInterval(my_report.interval)} if(!!pTime){ my_report.interval = setInterval(function(){my_report.call_refresh()},pTime * 1000);} } this.call_refresh = function(){ $a_report(this.id.substring(1),this.id.start_record,this.num_record); } } function highlight(r) { var i = r.parentNode.parentNode.rowIndex; var table = r.parentNode.parentNode.parentNode.parentNode var id_ope = table.rows.cells[1].innerText;
// set PXX_ID_OPERATION item
$x('P83_ID_OPERATION').value=id_ope;
my_report1.call_refresh();
my_report2.call_refresh();
return true;
}
SelectThis works (almost) fine. When I select a row, the variable P83_ID_OPERATION is correctly set but the 2 reports are not refreshed. I changed the request behing the report my_report1 to debug it with a very basic select :
TO_CHAR (sysdate, "the HH24: MI: SS DD/MM/YYYY) mydate,: P83_ID_OPERATION myid
of the doubleI constat that the report is really refreshed by the call_refresh function (the date is changed at every call) but the P83_ID_OPERATION item is not correctly passed during the recall (I keep a previous value !). Where is my mistake ? Is my P83_ID_OPERATION only local ? Is there a way to decalre it as global and share it with all the dependent embedded report ? Thank in advance and happy new year... Edited by: 975489 on Dec 31, 2012 5:32 AM
rlebret wrote:
Hi ErikIndeed, it works... Thank you very much for the article that explained to me life ajax (dura lex, sed lex!).
A quick update however...I need set several page elements in different parts of the code/pages.
Is it possible to use a process very simple generic application for all initialization instead of declare the variable in the code... Basically, I just need to initialize a page of a value element...I tried...
BEGIN :apex_application.g_x01:=apex_application.g_x02;;
First of all that this will not work because it is syntactically incorrect. + (Two; at the end).
It will not work even if solve you this problem.and
ajaxReq.addParam('x01','P83_ID_OPERATION'); ajaxReq.addParam('x02',$v('P83_ID_OPERATION'));
... but it does not work. An idea for a generic statement?
You can try this
BEGIN APEX_UTIL.SET_SESSION_STATE(apex_application.g_x01,apex_application.g_x02); END;
Thank you
Vikram -
Get the values and elements of object property
If I have an object,
MyObject = ({a: 3, b:5, c:8})})
How can I get a list of items and their values according to their position
Let's say I want to know what the name of the second element, how can I get the answer "b"?
In addition, without knowing the name of the element how can I get the value of the second item "5"?
Thank you
Trevor
It is, of course, a matter of Javascript, and the answer is not specific to InDesign, but I think you knew that already.
The short answer is: you do not have. JavaScript does not have something on the positioning of the members of an object.
There is no guarantee that b will remain the second element, and there is no way to get the members of an object by a sort of index rather than by their name.
BTW, you write:
MyObject = ({a: 3, b:5, c:8})})
Which is too complex (extra parens) and missing a semicolon from the finish line. It is better written as:
MyObject = {a: 3, b:5, c:8};
You can iterate through the names of the keys of myObject, with i in myObject {...}, but still there is no guarantee of order. In ExtendScript, you could use myObject.reflect.properties to return the keys in a table, but you will get some extra junk and it's not really consider good practices to use the objects of reflection in non debug code.
If you are wanting to do this, you are probably not using objects correctly.
Can you tell us more about the problem you are trying to solve, please?
-
Development of the APEX element via javascript
I'm fighting to set the value of an element of the APEX of the javascript.
At the moment I have a button on Page 1 that has a URL action. The URL points to
JavaScript:getConfirmation('&APP_SESSION.');
and my function is
< script type = "text/javascript" >
function getConfirmation (sessionNumber) {}
var response = confirm (' remove this step remove also all the dependencies that depend on this step.) ») ;
{if (Answer)}
html_SetSelectValue (P4_CREATED_STEP, 'YTest');
document.getElementById('P4_CREATED_STEP').value = "YTest1";
} else {}
html_SetSelectValue (P4_CREATED_STEP, 'Packers');
document.getElementById('P4_CREATED_STEP').value = "NTest1";
}
Window.Location.href = "http://appsit-dev-10g.oraclecorp.com/pls/aitmarvel/f?p=101:3:"+ open; "
}
< /script >
I see that I get no error javascript via the Firefox error console.
However when I redirect to page 2 with the javascript call. The value of 'P4_CREATED_STEP' is undefined.
Help, please.Hello
You do not submit the page or use AJAX to set the item session state.
This might helphttp://www.oracleapplicationexpress.com/tutorials/68
http://Apex-at-work.blogspot.com/2010/02/set-item-value-with-AJAX.htmlBR, Jari
Maybe you are looking for
-
is it possible to print a list of the books in the iBooks library
I have a very large library in iBooks and you want to print a "catalogue" of these books. Anyone know how this can be done?
-
I have a labeled mailbox 'Outbox'. I don't know where he is but I don't want that. The 'delete mailbox' from the menu of the mailbox down is not available then, how can I get rid of him.
-
Satellite A200-20Y load a few seconds
Hello My Sattellite A200-20Y load a few seconds. I plug the charger on the laptop and the charge indicator lights up in just a few seconds and then it turns off the light. I tested the charger and it works well and I have also tested it with another
-
HPM9265: HPM9265 AHCI support for SSD
Y at - it a reliable update for the 'Intel Matrix Storage manager Option ROM v 7.6.6.1002 ICH9R' which will allow my SSD running with AHCI?
-
Rundll32.exe should not be run?
Recently, I noticed that two rundll32.exe process running, how to time its has been actually done that, I don't know. A process uses somewhere about 1 600 K of memory at the present time, the other is using 3 100 K. However, whenever I get on a gam