T
tenshi04
Hi,
I am trying to get a code snippet from a database and use the snippet
within the Javascript eval() function. The snippet is a an if-else,
statement that sets a certain value. Here is the code below:
-----------------------------------------------------
var sLogicKey = "ATR_PROD_DIV";
var sGetLogicSQL = "SELECT LOGIC_TEXT FROM ATR_LOGIC WHERE LOGIC_KEY =
'" + sLogicKey + "'";
var oDB = new DataManager(sGetLogicSQL); //gets a connection
var oRsLogic = oDB.executeQuery();
var sLogicText = "";
if (oRsLogic.size() > 0)
{
sLogicText = oRsLogic.getRow(0).getString(1);
}
sProdDiv = eval(sLogicText);
-----------------------------------------------------------
this basically just pulls a string out from the database where the
LOGIC_KEY field is equal to "ATR_PROD_DIV".
the result of the query is (and essentially the value of sLogicText):
--------------------------------------------------------------
if (sSalesDiv.equals('D') && (sTemp.equals('S5F') ||
sTemp.equals('S9V') || sTemp.equals('SJC') || sTemp.equals('SVA') ||
sTemp.equals('SVB') || sTemp.equals('SNH') || sTemp.equals('SVJ') ||
sTemp.equals('SVH')))
{
sProdDiv = 'A';
}
else if (sSalesDiv.equals('D') && (sTemp.equals('S3V') ||
sTemp.equals('STX')))
{
sProdDiv = 'B';
}
sProdDiv = sProdDiv + '';
---------------------------------------------------------
When sLogicText is passed into eval(), the logic is not evaluated and
instead, sLogicText value is simply returned back.
Anyone have ideas as to what might be wrong?
thanks.
I am trying to get a code snippet from a database and use the snippet
within the Javascript eval() function. The snippet is a an if-else,
statement that sets a certain value. Here is the code below:
-----------------------------------------------------
var sLogicKey = "ATR_PROD_DIV";
var sGetLogicSQL = "SELECT LOGIC_TEXT FROM ATR_LOGIC WHERE LOGIC_KEY =
'" + sLogicKey + "'";
var oDB = new DataManager(sGetLogicSQL); //gets a connection
var oRsLogic = oDB.executeQuery();
var sLogicText = "";
if (oRsLogic.size() > 0)
{
sLogicText = oRsLogic.getRow(0).getString(1);
}
sProdDiv = eval(sLogicText);
-----------------------------------------------------------
this basically just pulls a string out from the database where the
LOGIC_KEY field is equal to "ATR_PROD_DIV".
the result of the query is (and essentially the value of sLogicText):
--------------------------------------------------------------
if (sSalesDiv.equals('D') && (sTemp.equals('S5F') ||
sTemp.equals('S9V') || sTemp.equals('SJC') || sTemp.equals('SVA') ||
sTemp.equals('SVB') || sTemp.equals('SNH') || sTemp.equals('SVJ') ||
sTemp.equals('SVH')))
{
sProdDiv = 'A';
}
else if (sSalesDiv.equals('D') && (sTemp.equals('S3V') ||
sTemp.equals('STX')))
{
sProdDiv = 'B';
}
sProdDiv = sProdDiv + '';
---------------------------------------------------------
When sLogicText is passed into eval(), the logic is not evaluated and
instead, sLogicText value is simply returned back.
Anyone have ideas as to what might be wrong?
thanks.