473,795 Members | 3,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

arithmatical headache (Dr J?)

FOA I want to apologize because the page below is in Hebrew and you'll see
giberish. But for the brave here is the link. www.carmenchange.com Either
the left or right select box must be set to default (local currency)
otherwise it evaluates the sale with the foreign currencies. Enter the
amount under the foreign currency. Every once in a while if fudges. 2.50 X
10 =24.9........06

for those who can deal with the code
these functions read a file (jk.js) whose format is
var curr1=new Array();
curr1.name="nam e";
curr1.buy='4.46 00';
curr1.sell='4.3 900';
curr1.rep='4.14 80';
.....
currn = etc;
the html contains two select boxes named "inCurrency " and "outCurrenc y" and
two text inputs for them and the functions below process the input from the
text inputs. I've only tested with numbers so feed it at your own risk!!
There are slight differences in the two functions below but both 'seem' to
behave the same. I could really use some help here. I just want to multiply
two values and reformat them. Maybe regexes would be better but I'm weak.
BTW I'm testing with IE5.0 on (phtu) Windows 98
function setOutPrice(amo unt) {
// typeof amount // returns number
if(isNaN(parseI nt(amount))) return false; // extra check for good integer
if(!document.fo rms[0].outCurrency.se lectedIndex) return;
var a,b,obj=documen t.forms[0];
if(obj.inCurren cy.selectedInde x) return;
// I have tried replacing the eval with
// b=window["curr"+obj.outC urrency.selecte dIndex]; b=b.buy;
// and the results are slightly different but just as bad
b=eval("curr"+o bj.outCurrency. selectedIndex+" .buy");
a=parseInt(amou nt)*parseFloat( b);
obj.inPutPrice. value=fixString (a);
}
function setInPrice(amou nt) {
oObj=document.f orms[0].outCurrency;
iObj=document.f orms[0].inCurrency;
if(isNaN(parseI nt(amount))||!i Obj.selectedInd ex) return;
var a,b;
if(oObj.selecte dIndex&&iObj.se lectedIndex) {
forCurrTrans(oO bj,iObj);
return;
}
b=eval('curr'+i Obj.selectedInd ex+'.sell');
a=amount*b;
document.forms[0].outPutPrice.va lue=fixString(a );
}
function fixString(amt) { // trying to fix the results and format
var a = parseInt(amt*10 0)/100+'';
var b=a.indexOf('.' );
if(b==-1) a+='.00';
if(a.length-b==2) a+='0';
return a;
}

Jul 23 '05
11 1264
In article <20************ ****@PointedEar s.de>, Thomas 'PointedEars'
Lahn <Po*********@we b.de> writes
John G Harris wrote:
Your jk.js file would now be
var curr = new Array(); // This one is a real array
curr[1] = new Object();
curr[1].name = "name";
...
curr[2] = new Object();
...

or you could write
curr[1] = { name:"name", buy:'4.4600', ... };


Or he could write

var curr = [
{ name:"name", buy:'4.4600', ... },
...
];


But not if he really did want to index from 1.

John
--
John Harris
Jul 23 '05 #11
John G Harris wrote:
In article <20************ ****@PointedEar s.de>, Thomas 'PointedEars'
Lahn <Po*********@we b.de> writes
John G Harris wrote:
Your jk.js file would now be
var curr = new Array(); // This one is a real array
curr[1] = new Object();
curr[1].name = "name";
...
curr[2] = new Object();
...

or you could write
curr[1] = { name:"name", buy:'4.4600', ... };


Or he could write

var curr = [
{ name:"name", buy:'4.4600', ... },
...
];


But not if he really did want to index from 1.


Well, there is a solution:

var curr = [
null, // or whatever non-reference value you want
{ name:"name", buy:'4.4600', ... },
...
];
PointedEars
--
Whose cruel idea was it for the word "lisp" to have an "s" in it?
Jul 23 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2612
by: David | last post by:
On every web browser except Safari, this website works great. (Well, by "every" I mean Mozilla, Netscape, and Internet Explorer, for Mac and Windows). The site is: http://www.ruleofthirds.com (the problem does not exist on the first page... just all the other pages, so you'll have to click on something to see the problem) The problem lies with images swapping on rollover. I use a small
5
1645
by: Ryan Ternier | last post by:
I'm having an issue with an SQL insert statement. It's a very simple statement, and it's causing too much fuss. strSQL = "INSERT INTO tblFieldLayouts(TypeID, FieldID, OrderID, Hidden) VALUES(" & intTypeID & ", " & intFieldID & ", " & intOrderID & ",0)" comFields.CommandText = strSQL comFields.ExecuteNonQuery()
3
2122
by: laurenq uantrell | last post by:
I'm trying to return an integer from the following table that returns the number of unique cities: tblEmployees Name City John Boston Frank New York Jim Omaha Betty New York
12
1351
by: NuB | last post by:
The validation controls are giving me a headache. here is what i'm trying to do and so far what I've tried has not worked. I need to hide my grid if the page is not valid how can i accomplish that? I have one validation control that gives an error if there is no data returned, so if the page is not valid on another search i need that to go away. How can i hide and show controls and labels bases on the page.isvalid
5
1424
by: James Ma | last post by:
Now I am debugging a buggy VB.NET function like following Function foo() Try ‘ many loops and codes and nested try catch here! …… Catch (ex as Exception) Msgbox ex.message Finally …
3
1456
by: Echo | last post by:
Hi all. Sorry about the crude headline but this problem is really giving me a headache. See I am currently deloping an app in Visual Studios 2005 C# Lanuage and the thing is like this: I have a DataGridView on my form. In this DataGridView is a DataGridViewCheckBoxColumn and I want to get the value (either true or false) as I click on the cell(meaning when I change the checked box unchecked or the other way around) Now like a regular...
12
1627
by: Krij | last post by:
Hi! A button on frmOrders will let user return an order. But... The following SQL is giving me a headache: strPutBack = "INSERT INTO tblAmountItems(Amount,MyDate,Returned) " _ & "SELECT Amount,MyDate,Returned " _ & "FROM tblOrderdetails " _ & "WHERE tblOrderdetails.Returned = True
1
1023
gchq
by: gchq | last post by:
Hi there Attempting to populate a dynamic table with data - that in itself is not a problem, but getting group headers IS giving me a headache. Know I've done this before, but can I remember how? Data is brought in using odbcDataReader then read between 'while' and 'end while' statements into dynamic rows. The group headers (Category) are held in the same database table Platform is VB.Net
2
1396
by: plemon | last post by:
this script was working now ive added to it and its no longer my friend. here is the very first one <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;
9
1706
by: pandaking | last post by:
Hi there everyone, new here but after reading around it seems like I might hang about - so many helpful threads! I have a slight problem. This flying club near me has employed me to make them a database. I got into it because I know one of the guys who works there, and he mentioned they need one and I did Computing A level a few years back so I thought it would be a doddle and some much needed cash! Well it's a headache :( It's...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10437
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.