By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,587 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,587 IT Pros & Developers. It's quick & easy.

Javascript eval() won't work.

P: n/a
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.

Feb 21 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
<te******@gmail.comwrote:
<snip>
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?
That would happen whenever sLogicTest's value was anything but a string
primitive (for example, a String object).

Richard.

Feb 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.