473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Javascript eval() won't work.

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
1 1278
<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
7
by: Marci | last post by:
I found this script for cascading menus, however, I cannot reach the author to solve the bug I am having when I add a second menu to it. My problem is this: If I click on the first link, the...
4
by: binnyva | last post by:
Hello Everybody, I am writing an interactive tutorial for JavaScript. I created a text box into which the users can input javascript commands. On pressing a button, these commands will be...
6
by: John | last post by:
Whenever the following script is called, it always defaults to the default CASE (14.99) Why won't it recognise the other range of values? Please I need help. <script language="javascript"...
8
by: | last post by:
The problem lies here eval("document.TeeForm.amt.value(S+M)"); S and M suppose to add up and the total suppose to appear on the AMT field but it didn't. Any help? ...
10
by: John Passaniti | last post by:
(Note: This is not the same message I posted a week or so ago. The problem that prevented my previous attempt to work was a silly error in the template system I was using. This is a problem...
17
by: yawnmoth | last post by:
http://www.frostjedi.com/terra/scripts/demo/this-alert.html http://www.frostjedi.com/terra/scripts/demo/this-alert2.html Why, when you click in the black box, do the alert boxes say different...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.