Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Issue calling onchange javascript function

Tonito99Feb 12 2014

Hello,

I'm working on apex page (master detail page).

The requirement is to calculate total amount from tabular form and set it to total field on master region.

And then total field should be calculated with profit field from master region.

I setup a javascript function which does calculation from tabular region and set total field on master region.

Issue is that grand total of master region is not calculated, even for calculation of grand total I setup another function which is called onchange of tabular form total.

onchange="CreditAmountTotal(), SellingPrice();"

CreditAmountTotal()      -- Is working as expected

SellingPrice()                -- Not doing calculation called from tabular region, it's working when is called from items on master region

grand total = total + profit

function CreditAmountTotal()

{

  var items = document.getElementsByName("f07"); // Tabular form column to add up

 

  $total = 0;

  $itemValue = 0;

  for (var i = 0; i < items.length; i++)

  { 

   // if non-numeric character was entered, it will be considered as 0,

   // isNaN returns true if anything but number was entered

   if(isNaN(items[i].value) || items[i].value == null || items[i].value == "")

    $itemValue = 0;

   else

    $itemValue = parseFloat(items[i].value); // convert to number

  

   $total =$total+ $itemValue; // add up

  }

 

  // $x sets the text field to be updated to the column total just calculated

  $x('P20_AMOUNT').value = $total;

}

  function SellingPrice(){

    function getVal(item){

   if(document.getElementById(item).value != "")

     return parseFloat(document.getElementById(item).value);

   else

     return 0;

    }

    document.getElementById('P20_SELLING_PRICE').value =

  getVal('P20_AMOUNT') + getVal('P20_TOTAL_PROFIT_AMOUNT') + getVal('P20_PARTICIPATION_AMOUNT');

  }

Application Express 4.2.2.00.11

Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production

Regards,

Tonito         

Comments

285751
Try adding a parameter 0 before your oraParmSessionID parameter. That will give the function someplace to return its result.

OraParameter oraReturn = new OraParameter();
oraReturn.ParameterName = "justaboutanything";
oraReturn.OraDbType = OraDbType.Date;
oraReturn.Direction = ParameterDirection.ReturnValue;
oraCommand.Parameters.Add(oraReturn );




Any ideas as to what's causing the following error:
---
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Oracle.DataAccess.Client.OraException:
/---
I'm simply calling an Oracle function which returns a date. Code snippet:
---
FUNCTION func_get_session_date(v_session_id VARCHAR2, v_session_key VARCHAR2) RETURN DATE IS
...etc
/---
...employing the OraDataReader to extract the value (unnecessary code extracted for clarity):
---
DateTime returnDateTime;
string commandText = "SELECT pkg_css_session_state.func_get_session_date(:v_session_id, :v_session_key) FROM dual";
//string commandText = "SELECT pkg_css_session_state.func_get_session_date('" + this.AspxSessionID + "', '" + sessionKey + "') FROM dual";
OraConnection oraConnection = new OraConnection(connectionString);
OraCommand oraCommand = new OraCommand();
oraCommand.Connection = oraConnection;
oraCommand.CommandText = commandText;
OraParameter oraParmSessionID = new OraParameter();
oraParmSessionID.ParameterName = "v_session_id";
oraParmSessionID.OraDbType = OraDbType.Varchar2;
oraParmSessionID.Value = this.AspxSessionID;
oraParmSessionID.Direction = ParameterDirection.Input;
oraCommand.Parameters.Add(oraParmSessionID);
OraParameter oraParmSessionKey = new OraParameter();
oraParmSessionKey.ParameterName = "v_session_key";
oraParmSessionKey.OraDbType = OraDbType.Varchar2;
oraParmSessionKey.Value = sessionKey;
oraParmSessionKey.Direction = ParameterDirection.Input;
oraCommand.Parameters.Add(oraParmSessionKey);
oraConnection.Open();
OraDataReader oraDataReader = oraCommand.ExecuteReader(CommandBehavior.CloseConnection);
if (oraDataReader.Read())
{
if (! oraDataReader.IsDBNull(0))
{
returnDateTime = oraDataReader.GetDateTime(0);
}
}
/--
Interestingly, it works fine when I don't use input parameters (see commented-out commandText string).
Thanks ahead o' time!
1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 12 2014
Added on Feb 12 2014
0 comments
832 views