Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Javascript eval() won't work.

Reply
Thread Tools

Javascript eval() won't work.

 
 
tenshi04@gmail.com
Guest
Posts: n/a
 
      02-21-2007
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.

 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      02-21-2007
<(E-Mail Removed)> wrote:
<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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generated JavaScript vs. Manually Created JavaScript: Which one comes first? Nathan Sokalski ASP .Net 4 11-08-2007 07:24 AM
JavaScript or not JavaScript Mark Rae ASP .Net 36 09-09-2006 01:12 PM
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
Javascript -> Applet: variable reset after method call from javascript?! mcdeveloper Java 1 06-13-2006 08:34 AM
To Javascript, or not to Javascript Shane NZ Computing 5 08-30-2005 09:33 PM



Advertisments