473,386 Members | 1,799 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,386 software developers and data experts.

accessing Object()...

Hello All,
I have created a custom object()
var o_table = new Object();

o_table['0'] = 240;
o_table['1'] = 241;
o_table['2'] = 242;
o_table['3'] = 243;
o_table['4'] = 244;
o_table['5'] = 245;
o_table['6'] = 246;
o_table['7'] = 247;
o_table['8'] = 248;
o_table['9'] = 249;
o_table['A'] = 193;
o_table['B'] = 194;
o_table['C'] = 195;
o_table['D'] = 196;
o_table['E'] = 197;
o_table['F'] = 198;
o_table['G'] = 199; // *
o_table['H'] = 200;
o_table['I'] = 201; // **
o_table['J'] = 209;
o_table['K'] = 210;
o_table['L'] = 211;
o_table['M'] = 212;
o_table['N'] = 213;
o_table['O'] = 214; // **
o_table['P'] = 215;
o_table['Q'] = 216; // **
o_table['R'] = 217;
o_table['S'] = 226; // *
o_table['T'] = 227;
o_table['U'] = 228;
o_table['V'] = 229;
o_table['W'] = 230;
o_table['X'] = 231;
o_table['Y'] = 232;
o_table['Z'] = 233; // **

I have a seven character string I get from an input in a form. I need
to take the characters from this string and I do this...

var splitupaa = doc.aainput.value.split("");//0 - 6

so now I have an 'array'.

QUESTION:
How can I take splitupaa[] and equate the value to the key in the
Object() ???

ex if input string is 1234567
in my object
1 = 240
2 = 241
etc.

I need to compute an algorithm with the values from the object relative
to the array values.

Thanks in advance!
( I am starting to like JS now ;) )
Cmac

Feb 15 '06 #1
7 1130
Cmac wrote:
Hello All,
I have created a custom object()
var o_table = new Object();

o_table['0'] = 240;
o_table['1'] = 241; [...] o_table['Y'] = 232;
o_table['Z'] = 233; // **
Consider initialising that with:

var o_table = {
'0' : 240,
'1' : 241,
[...]
'Y' : 232,
'Z' : 233
}
Are the values ever used as numbers? If not, why not make them strings?

var o_table = {
'0' : '240',
'1' : '241',
[...]
'Y' : '232',
'Z' : '233'
}

I have a seven character string I get from an input in a form. I need
to take the characters from this string and I do this...

var splitupaa = doc.aainput.value.split("");//0 - 6

so now I have an 'array'.

QUESTION:
How can I take splitupaa[] and equate the value to the key in the
Object() ???

ex if input string is 1234567
in my object
1 = 240
2 = 241
etc.

I need to compute an algorithm with the values from the object relative
to the array values.


function encodeStr(s)
{
s = String(s).split('');
var s2 = '';
for (var i=0, len=s.length; i<len; ++i){
s2 += o_table[s[i]];
}
return s2;
}
Or:

function encodeStr(s)
{
s = String(s).split('');
var s2 = [];
for (var i=0, len=s.length; i<len; ++i){
s2.push(o_table[s[i]]);
}
return s2.join('');
}


--
Rob
Feb 16 '06 #2
Thanks for the reply Rob,
I will play with this and see what I come up with. :D

Feb 16 '06 #3
var ibmalgo = new Object();

ibmalgo['0'] = 240;
ibmalgo['1'] = 241;
ibmalgo['2'] = 242;
ibmalgo['3'] = 243;
ibmalgo['4'] = 244;
ibmalgo['5'] = 245;
ibmalgo['6'] = 246;
ibmalgo['7'] = 247;
ibmalgo['8'] = 248;
ibmalgo['9'] = 249;
ibmalgo['A'] = 193;
ibmalgo['B'] = 194;
ibmalgo['C'] = 195;
ibmalgo['D'] = 196;
ibmalgo['E'] = 197;
ibmalgo['F'] = 198;
ibmalgo['G'] = 199;
ibmalgo['H'] = 200;
ibmalgo['I'] = 201;
ibmalgo['J'] = 209;
ibmalgo['K'] = 210;
ibmalgo['L'] = 211;
ibmalgo['M'] = 212;
ibmalgo['N'] = 213;
ibmalgo['O'] = 214;
ibmalgo['P'] = 215;
ibmalgo['Q'] = 216;
ibmalgo['R'] = 217;
ibmalgo['S'] = 226;
ibmalgo['T'] = 227;
ibmalgo['U'] = 228;
ibmalgo['V'] = 229;
ibmalgo['W'] = 230;
ibmalgo['X'] = 231;
ibmalgo['Y'] = 232;
ibmalgo['Z'] = 233;

var splitupaa = doc.aainput.value.split("");//0 - 6
//A1 + A3 + A3 + A5 + A4 + A6 / 5
var calculation = (ibmalgo[splitupaa[0]] + ibmalgo[splitupaa[2]] +
ibmalgo[splitupaa[2]] + ibmalgo[splitupaa[4]] + ibmalgo[splitupaa[3]] +
ibmalgo[splitupaa[5]]) / 5;
document.write(calculation);
This does not do what I want it to, but maybe you will see what I am
trying to do???

Feb 16 '06 #4
That looks correct to me, what is your input string, and your output
calculation?

Feb 16 '06 #5
you are skipping charecter at index 1, and adding the charecter at
index 2 twice, i'm assuming this is what you want to do... also if
you're looking for the average, there are 6 charecters at indexes 0 to
5... I'm guessing you knew all this already but i thought i'd point it
out anyways

Feb 16 '06 #6
Thanks, this is how I fixed the issue:

var ibmalgo = new Object();

ibmalgo['0'] = 240;
ibmalgo['1'] = 241;
ibmalgo['2'] = 242;
ibmalgo['3'] = 243;
ibmalgo['4'] = 244;
ibmalgo['5'] = 245;
ibmalgo['6'] = 246;
ibmalgo['7'] = 247;
ibmalgo['8'] = 248;
ibmalgo['9'] = 249;
ibmalgo['A'] = 193;
ibmalgo['B'] = 194;
ibmalgo['C'] = 195;
ibmalgo['D'] = 196;
ibmalgo['E'] = 197;
ibmalgo['F'] = 198;
ibmalgo['G'] = 199;
ibmalgo['H'] = 200;
ibmalgo['I'] = 201;
ibmalgo['J'] = 209;
ibmalgo['K'] = 210;
ibmalgo['L'] = 211;
ibmalgo['M'] = 212;
ibmalgo['N'] = 213;
ibmalgo['O'] = 214;
ibmalgo['P'] = 215;
ibmalgo['Q'] = 216;
ibmalgo['R'] = 217;
ibmalgo['S'] = 226;
ibmalgo['T'] = 227;
ibmalgo['U'] = 228;
ibmalgo['V'] = 229;
ibmalgo['W'] = 230;
ibmalgo['X'] = 231;
ibmalgo['Y'] = 232;
ibmalgo['Z'] = 233;

var splitupaa = doc.aainput.value.split("");//0 - 6
var A1 = splitupaa[0].toUpperCase();
var A2 = splitupaa[1].toUpperCase();
var A3 = splitupaa[2].toUpperCase();
var A4 = splitupaa[3].toUpperCase();
var A5 = splitupaa[4].toUpperCase();
var A6 = splitupaa[5].toUpperCase();
var A7 = splitupaa[6].toUpperCase();

//A1 + A3 + A3 + A5 + A4 + A6 / 5
var calculation = (ibmalgo[A1] + ibmalgo[A3] + ibmalgo[A3] +
ibmalgo[A5] + ibmalgo[A4] + ibmalgo[A6]) / 5;

I really appreciate all your help out there in interweb land ;-)
Cmac

Feb 16 '06 #7
save some typing:

var splitupaa = doc.aainput.value.toUpperCase().split("");

=)

Feb 16 '06 #8

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

Similar topics

4
by: Jaydeep | last post by:
Hello, I am facing a strange problem. Problem accessing remote database from ASP using COM+ server application having VB components (ActiveX DLL) installed. Tier 1 : ASP front End (IIS 5.0) Tire...
5
by: Sandeep | last post by:
Hi, In the following code, I wonder how a private member of the class is being accessed. The code compiles well in Visual Studio 6.0. class Sample { private: int x; public:
4
by: Eugen Walcher | last post by:
Hello all, I've tried posting this same question on other newsgroups with no luck. This group seems to have a lot more activity so I apologize if you have seen it before. I'm trying to...
3
by: Alex | last post by:
I'm having a problem porting an ASP solution to ASPX. In the ASP solution I'm accessing a DCOM server, create sub DCOM objects and call functions from VB script on the ASP pages. The DCOM object...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
0
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
8
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList...
16
by: s0suk3 | last post by:
This code #include <stdio.h> int main(void) { int hello = {'h', 'e', 'l', 'l', 'o'}; char *p = (void *) hello; for (size_t i = 0; i < sizeof(hello); ++i) {
0
by: Roger Stoller | last post by:
Hello. I have developed a COM object using ATL. It seems to work fine when accessing it from VB.NET most of the time. However, I want to use a delegate in VB to asynchronously run a method in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.