Round value in java script

hi,
I have to calculate Salary into textfield .
Problem is after Calculation salary amount 1230.3566678787 like this come into text field.
i want only 1230.35 amount.
<script>
function multiplyItems(){
function getVal(item){
if($x(item).value != "")
return parseFloat($x(item).value);
else
return 0;
$x('P65_SALARY').value =getVal('P65_ADVANCE_PAYMENT')+
getVal('P65_OVR_TM_AMT')+getVal('P65_BONUS') + getVal('P65_OTHER_CHARGES')-getVal('P65_LEAVE_AMOUNT');
</script>How can i do this in java script.

Change your code as below.
<script>
function multiplyItems(){
function getVal(item){
if($x(item).value != "")
return parseFloat($x(item).value);
else
return 0;
$x('P65_SALARY').value =Math.round((getVal('P65_ADVANCE_PAYMENT')+getVal('P65_OVR_TM_AMT')+getVal('P65_BONUS') + getVal('P65_OTHER_CHARGES')-getVal('P65_LEAVE_AMOUNT'))*100)/100;
</script>Better if you post a javascript question in a javascript forum. Chances of getting a solution will be increased.

Similar Messages

  • How to get/read region item value in java script

    Hi All,
    i have text item on a page.
    how to read the item value in java script
    EXAMPLE
    P10_RESULT IS ITEM IT HAS VALUE "38.956472,-77.447777","38.999123,-77.026184","12.951497,70.668646","17.459075,78.456888"
    NOW I WANT TO REFER ABOVE ITEM VALUE IN JAVA SCRIPT LIKE
    var myPoints=new Array(&P10_RESULT.);
    SO I CAN POPULATE ARRAY WITH CORDINATES
    IT IS NOT WORKING
    WHAT IS THAT I AM MISSING.
    PLESE HELP .
    ThankS
    Rk

    region header code....
    <script src="http://maps.google.com/maps?file=api&v=2&key=&API_KEY." type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
    //globals
    var bounds = new GLatLngBounds();
    var map;
    var centerPoint = new GLatLng(38.984898,-76.854549);
    var gmarkers = [];
    //var x= ""38.956472,-77.447777","38.999123,-//77.026184","12.951497,70.668646","17.459075,78.456888"";
    //var myPoints=new Array(x);
    //var myPoints=new Array($x('P10_RESULT').value);
    var myPoints=new Array(document.getElementById('P10_RESULT').value);
    //var myPoints=new Array("38.956472,-77.447777","38.999123,-77.026184","12.951497,70.668646","17.459075,78.456888");
    function initMap()
              doLoad();
                        addMarkers();
    function doLoad()
         if (GBrowserIsCompatible())
                   map = new GMap2(document.getElementById("map"));
                   map.setCenter(centerPoint, 7);
                   map.addControl(new GScaleControl());
                   map.addControl(new GLargeMapControl());
                   map.addControl(new GMapTypeControl());
    function myclick(i) {
    GEvent.trigger(gmarkers, "click");
    function addMarkers() {
         if (myPoints.length) {
              var bounds = new GLatLngBounds();
              for (n=0 ; n < myPoints.length ; n++ ) {
                   var mData = myPoints[n].split(',');
                   var point = new GLatLng(mData[0],mData[1]);
                   bounds.extend(point);
                   var marker = createMarker(mData[1],point, mData[0]);
         map.addOverlay(marker);
              map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
    function createMarker(i,point, title) {
         var marker = new GMarker(point,{title:title});
         GEvent.addListener(marker, "click", function() {
              marker.openInfoWindowHtml('<div style="width:250px;">' + title + '<hr>Lat: ' + point.y + '<br>Lon: ' + point.x + '</div>');
         gmarkers[i] = marker;
         return marker;
    //]]>
    </script>
    page body code
    onload="initMap()" onunload="GUnload()"

  • Setting the XML tag value in Java script

    Hi,
       I am trying to set a XML tag value in the initialize event of a text field.. The code works fine in FormCalc but I needed it to work in java script.
         FormCalc:
         $record.prospectApplication.typeName = "namedInsured";
         Java Script:
         xfa.record.prospectApplication.typeName = "namedInsured";
         The above JavaScript does not work. Can any one help on this?
    Thanks
    Srini

    Hi Srini,
    In JavaScript you don't get any default properties so you need to say;
    xfa.record.prospectApplication.typeName.value = "namedInsured";
    That is assign the value to the "value" property not the dataValue object.

  • Getting Object Value in Java Script.

    Hello,
    I am having a Graph apprearing on my Browser, I have used the Web Templates for this.
    When there the Query does not return any Data they Graph is not displayed and i get a message "No Application Data Found".
    Is there any way for me to capture this Message is Java Script and make Hide this message and from the user, any help will be highly appreciated.
    Best Wishes,
    Venkat.

    Sorry, this is a JSF forum, not a Javascript forum. There are JS forums at webdeveloper.com and dynamicdrive.com.
    As you're posting this in a JSF forum, I suspect that you don't understand in depth how JSF and JS works. I would then tell you one very important thing: Javascript doesn't see anything from JSF, it only sees the HTML DOM tree which is generated by JSF. Open a JSF page in your webbrowser, do a 'view source', that's all what JS sees. You need to base your JS code on that generated HTML/CSS/JS source. Good luck.

  • Dynamicly change SelectOneRadio value in java script function -- Please hel

    Hello, I need to change SelectOneRadio value within a javascript function. But it doesn't seem to work for me. Can someone tall me what I did wrong or how to get this?
    Thanks a lot!
    I have :
    <h:panelGrid Columns="3">
    <h:selectOneRadio id="myRadio", value="#{myBean.radioOption}" />
         <f:selectItems value="#{myBean.radioOptionList}" />
    </h:selectOneRadio>
    </h:panelGrid>
    <script >
    function needToChangeRadioValue(choice){
    if ( choice == something ) { 
         document.getElementById("myForm:myRadio").value="1"; //doesn't really work
         document.getElementById("myForm:myRadio").immediate="true";
    } else if ( choice == somethingelse ) {
         document.getElementById("myForm:myRadio").value="2"; //doesn't really work
         document.getElementById("myForm:myRadio").immediate="true";
    } else {
         document.getElementById("myForm:myRadio").value="3"; //doesn't really work
         document.getElementById("myForm:myRadio").immediate="true";
    </script>
    -- java --
    ArrayList radioOptionList;
    public ArrayList getRadioOptionList(){
         radioOptionList = new ArrayList();
         radioOptionList.put("1","Option1");
         radioOptionList.put("2","Option2");
         radioOptionList.put("3","Option3");
         return radioOptionList;
    }

    Thank you for the quick response!
    Does it work for you? I tryed getElementsByName("myform:myRadio")[1].value="1"; No errors but the screen doesn't show that radio button is "on". I also created another function to go through the form object and try to set the attribute but no luck. From screen, I still don't see the option is selected(or on). I have :
    <script .... >
    function checkRadioButton(){
    var allElem = document.forms['myform'].elements;
    for ( i=0 ; i< allElem.length; i++ ){
    alert("element name = " + allElem.name ); // I see myform:myRadio three times
    alert("element id = " + allElem[i].id ) // when name="myform:myRadio, id is null/empty
    alert("element value = "+ allElem[i].value ); // when name="myform:myRadio, value = 1, 2, 3 respectively
    if ( allElem[i].name == 'myform.myRadio' ) {
         var attributes = allElem[i].attributes;
    for ( j =0; j < attributes.length; j++) {
              if ( attributes[j].name == 'CHECKED' ) { // I found CHECKED is one of selectOneRadio's attributes
                   if ( i == 1) {
         attributes[j].value = true; // It still doesn't work. I didn't see that option1 get selected/on.
    What I am trying to do is common, I think !!?? Really appreciate your help.

  • Passing Value to Java Script Code in a BSP

    Hi Guys,
    In order to use BSP Extension in my BS i need to specify the "ID" for the field / Text area / Table i want to work with.
    Now these elements (Field / Text Area / Table) are created by SAP CRM automatically and i am not sure how i can get the name of the ID for such a element.
    I tried using FIREBUG in firefox to get this ID but the problem is that this ID changes dynamicaly and i cant hardcode it in my BSP application.
    Can anybody point help me taht how can i determine the ID dynamically at runtime and then use it in my BSP application.
    Thanks in advance.

    Hi,
           You can pass data from SAP to javascript in the following way. Suppose I have created an input field like
    <thtmlb:inputField id      = "IF1"
                       type    = "string"
                       visible = "false"
                       value   = "//mynode/myattr" />
    Note that I have bound the input field to a context node attribute. This is only necessary if you wish to access this field inside your controller methods.
    Now, you can access this input field in your javascript in the following way. Inside the script, setting th evalue or reading, whatever,
    document.all("<%= controller->component_id %>_IF1").value = "some text" ;
    Regards,
    Arun Prakash

  • Pass value of Java script variable to ABAP variable (in BSP)

    Hi,
    I have a Javascript variable declared in the SCRIPT tag of BSP layout page.
    I want to pass its value to ABAP variable, so that later I can do some computations using the ABAP variable.
    (ABAP variable is also declared in the same SCRIPT tag of BSP page)
    Would request to post a sample code, if possible.
    Would appreciate quick replies.
    Thanks & Regards,
    Nisha Vengal.

    just check this
    https://forums.sdn.sap.com/click.jspa?searchID=16240444&messageID=1191305

  • Share variable value between java script and jsp

    Hi, Firends:
    In my old web page I used a static array to hold a set of values, and now I want to use dynamic value from datbase.
    I created a bean to process database data and return resultset value to an array string.
    I convert my html page into jsp page, use "usebean" tag to call specific method, after done, how can I set the
    resultvaule to my script variable?
    It's urgent!! great thanks!

    Hello,
    Finally, the codes work! thanks for all the suggestion!
    The most important is "J" need <%= tag too. and do not forget the double quotation mark ("") while assigning the value.
    the code like following:
    <jsp:useBean id="ArrayBean" class="myProj.BeanServices"
    scope="page" >
    </jsp:useBean>
    <%! public String[] dataArray; %>
    <%
    dataArray = ArrayBean.getRecordsetReturn();
    %>
    <script language="JavaScript1.2">
    var MCC = new Array(<%=dataArray.length%>);
    <%for(int j =0; j < dataArray.length; j++){ %>;
    MCC[<%=j%>]="<%=dataArray[j]%>";
    <%}%>;
    </script>
    One more question:
    I found on the web server, if I used the same file name (asp file and js file, html file is ok.), seems the server always used the old compiled codes ignoring the code already changed, even after re-complile. I have to change the file name again and again.
    I worked on JDeveloper environment, it has a testing web server environment on my local, I am not sure if this situation will happen in the real server environment.
    How can I make any new updates go into effect immidiately! Do you know web server has some configuration to handle this?
    Thanks a gain!

  • Manipulating Textbox value with java script

    Hi,
    I need code to sum two textbox values in to third one. I tried to find out the object by
    $x('P1_A').value & document.getElementById('P1_A').value
    Both are not worked.
    Please help me
    thanks and regards,
    Rajesh

    Hi,
    I am not doing any manipulation at prasent, just i am passing the value of P1_A as parameter to this function to display the value in P1_B.
    <script type="text/javascript">
    function disp(PageItem)
    //alert (PageItem);
    html_GetElement('P1_B').Value=PageItem; // not giving any error and also not displaying value in P1_B
    document.getElementById('P1_B').Value=PageItem; // not giving any error and also not displaying value in P1_B
    $x('P1_B').Value=PageItem; //giving error Object Required
    </script>
    i wrote the code for P1_A HTML Form Element Attributes
    onBlur="disp(this.value);"

  • How to get the value in java script to JSP

    Hi,
    I have written an onclick function on each row and passing the primary key of the table to the javascript function. I want the value which I have passed to the javascript back in the jsp to delete the particular row. How can I achieve this.
    Thanks

    Thank you for your reply!! Here I am getting the values only into the javascript after I click a particular row in the table. So for the bean and action to get that particular vale I think I have to submit the form and then get the values back because its initially showing null. How do I submit the form and get the value back, so that I can delete particular row?

  • SAP WAD # value with Java Script

    HI Guys,
    i have written a code which can replace the # value for the charteristic with 'Blank'. the code works fine during the initial run .
    but i can not do any navigation on the query. like drag and drop.
    i am getting a error saying ' null pointer is missing and it is not a obhect in SAP BW.
    thanks,
    Sanjeev

    Hi Kumar,
    when you writting the code scenarios, consider the infoobjects that are  about to use for drilldown as one scenario, that works for you for drill down/across.
    Regards,
    Venkata Boga.

  • How to get h:inputText  value into java script

    I have 3 date input fields when the page loads first time those fields values are "null" and by default i am putting with some dates by using onload function
    function runOnLoad()
         var v1 = document.getElementById(document.getElementById("recordedDateProxy").value);
         var v2 = document.getElementById(document.getElementById("mystartingDateProxy").value);
         var v3 = document.getElementById(document.getElementById("myLastDateProxy").value);
         var v4 = document.getElementById(document.getElementById("reportsTypeProxy").value);
         if (v1 == null && v2 == null && v3 == null && v4 == null)
    setDate();
              setTwoDate();
    then,i am putting one date and making remaining two dates null (i.e disable two dates) when the page loads second time it was giving all the date fields null. But i know there is a value in one date field. but it was not taking that value so it was again calling setDate();
    setTwoDate();
    please help me

    no there are only 3 date fields and laso one is a radio button value. what i am doing is
    I have a jsp page in that 3 date fields are there and two radio buttons one is day type and one is month type if i choose day type radio them two date fields disable if i choose month type them first date field disable. ok
    i have a button which get reports and print them in the same page so when the page loads first time then u can see in first date field todays date and remaining two date fields fill with starting date and ending date ok because i am calling onload function in onload function i an getting the values of these fields when those are null them fill with dates
    after fetching the records page loads again and calling inload function again then it was againg taking all the fields null it was not taking the date what i have enterd thats y it was again putting the dafault values

  • Not able to retrieve netui hidden field values in java script

    I have problem in retrieving hidden field values in javascript
    I have declared hidden field as below,
    <netui:hidden dataSource="actionForm.selectedColumns" tagId="hiddenSelectedfield"></netui:hidden>
    and retrieving with tagId in javascript as below,
    obj1 = document.getElementById(tagId).style;
    its not getting value with tagId defined in netui tag.
    Any suggestion...
    Thanks,
    Amit

    Hi,
    I'm a new bee to this adobe forms and VBS.Could you explain more on that Fdf file or Can you send some documentation where i can go through of.
    Even i'm very much happy to share the pdf file..the problem is it is binded with the SAP browser.So i cant make a copy to my local system,But i can explain all the technical stuffs inside the form.
    The form is developed using adobe lifecycle designer,i can see the fields are defined in the design view.
    The fields which i'm accessing to enter the values are visible & Set user defined values..
    when you access through the SAP portal,it opens up inside the browser ..so every field you choose or select additional fields get added based on the selection..
    The "GetField" code you have shared works perfectly fine..i could read all data,or i could select a particular field to retrieve the field.
    But the "SetField" code you have shared locating the field but it is not writing the value into the field.I called a setfocus method on the particular field as well..then put f.value = fieldvalue still it chooses the particular field but didnt feed the value...
    is it possible to call a keystroke to the particular field?
    if you have any ideas please throw it up on me..i'll try all my possibilities.
    Thanks for your time !

  • Error in setting value of ComboBox in java script

    Hi All,
    I my jsp file I am doing the following in java script function:
    document.getElementById('form1:porcessCombo').value = strArray;
    where "strArray" is an array of Strings
    But this doesnt seem to be working....
    How do i assign an array of objects as Combo box value in Java Script?
    Please help!
    Thanks.

    Thanks for your quick reply...Couple of more
    questions:
    1.) I am now getting an error as notImplemented() -
    i think this is because of using .options....Am i
    right?
    2.) Could you please elaborate what "Option" ? I
    have an array of strings String[]....which i compute
    in a scriptlet and i access it using
    var list = <%=stringArray%>
    document.getElementById('form1:listCombo').options =
    list
    OR JUST
    document.getElementById('form1:listCombo').options =
    <%=stringArray%>
    Waiting for your replyFirst of all i would like to make some points clear,
    1) You cannot cast a Java String array object to Javascript Object...
    2) You have to create an array which would hold Option Object in it
    for a better understanding look at this code
    var arry1 = new Array("display1","display2";
    var arra2 = new Array("valu1","value2");
    var selectObj = document.getElementById("listCombo");
    selectObj.options.length = 0;
    for(var i=0;i<arry1.length;i++)
    selectObj.options.add(new Option(arry1,arry2[i]));
    or have a single array with options in it..
    var listArray = new Array(new Option("display","value").......);
    var selectObj = document.getElementById("listCombo");
    selectObj.options.length = 0;
    for(var i=0;i<listArray .length;i++)
    selectObj.options[i] = listArray[i];
    Hope I have made the concept clear....

  • Combine JSP with Java Script!

    Hi,
    I am writing a .jsp file. I am able to put value of jsp into my java script code like..
    var i = <%= k %>
    but, now my requirement is reverse. I need to put the value of java script variable i into jsp variable k.
    Someone told me that it is possible using eval function.
    Now, using eval function , I can do the following ...
    function xyz() //java script function
    eval(<% int k = 5; %>);
    but, I need to put the value of java script variable i into k.
    I tried eval(<% int k = %> + i);
    but it is not working that way.
    Can anyone tell me how can I achieve this? Please reply as soon as possible.
    Thanks

    Just came across this, and even though it's old, I thought Id add something to it since I know a lot got problems combining javascript and jsp; and that most usually don't provide enough info to get someone started.
    To be able to "use" Java variables inside a javascript, you need to pass them in the function call:
    <%
        String aVariableToPass = "tadaaaaa";
    %>
    <form onSubmit="myFunction(this,'<%=aVariableToPass %>')" method="post" name="myForm" action="">
       <table>
         <tr>
              <td>
                   <input type="submit" value=HitMe" name="submit"/>
              </td>
         </tr>
       </table>
    </form>The function:
    function myFunction(form, theVariablePassedIn)
             var accessToTheVariable = theVariablePassedIn;
    }Now use accessToTheVariable inside the javascript, or theVariablePassedIn directly if you please.
    Cincerely. P

Maybe you are looking for

  • Is it possible to export Final Cut Pro X or .MOV to DVD Studio Pro (Final Cut Studio)?

    Is it possible to export Final Cut Pro X projects or .MOV to DVD Studio Pro (from Final Cut Studio v.3)? I'm using the free trial of Final Cut Pro X and later acquired a copy of Final Cut Studio (FCP 7, Compressor 3.5, DVD Studio Pro 4, Color 1.5, Mo

  • Setting adapter Ldap in Oracle Virtual Directory

    I'm setting up a new adapter in Oracle Virtual Directory for a OpenLDAP, something curious happens does not enable me finish the button, another detail is when I click on SSL I get the following message: could not load certificate chain: java.lang.ex

  • How to know the debit of dowloading in ftp to use it in the progress bar

    hello i have a class that download file from the server , and another class (progress bar) i dont know how i can get the debit of downloading with(ftp jave) to use it in the progress bar if so have an idea or have used the progress bar in ftp getting

  • HANA XS Outbound Http Issue

    Hello all, We are unable to call http destination from XS . Below is the hana log: XsIpConnection   IPConnection.cpp(00072) : IPconnection can not initialize libsapcrypto. rc = -40 In XSJS service: HttpClient.request: request failed. The following er

  • Flash install scripting error

    When I try to install the Flash player (or acrobat reader) under Windows XP SP3, I get an "Internet Explorer Script Error" popup with a scripting error after the installation file is downloaded and begins to execute. "An error has occurred in the scr