?
Solved

Any easy ways of doing a VLOOKUP equivalent

Posted on 2006-04-27
3
Medium Priority
?
266 Views
Last Modified: 2008-01-09
I have a database which I am querying and then want to find specific information based on a criteria.
I was wondering if anyone knows of any good ways to do a VLOOKUP type function in JAVASCRIPT. Currently I have written a DO WHILE LOOP that loops until the criteria is found. However, it is not quite working the way I want it to because I am not used to DO WHILE LOOP (I use LOOP UNTIL in vb). The DO WHILE LOOP is currently looping and stopping one short of the row it is meant to get because of the WHILE bit. I have tried using < also instead of != but it does not appear to work. Basically I can't seem to get a logical equivalent of a LOOP UNTIL with the current code I am using. So can anyone answer my first question? If not then someone should beable to answer my second question.
Thanks


Example of coding:
//BID COMPLETED BY
fieldx = 1
do {
adjustid = (ActiveDocument.Sections["R_atm_adjustment"].Columns["Adjust Id"].GetCell(1) + 'a20');
  BidCompletedBy = ActiveDocument.Sections["R_atm_field_data"].Columns["Line Text"].GetCell(fieldx)
 fieldx += 1}
while ((adjustid) != ActiveDocument.Sections["R_atm_field_data"].Columns["adjust_field"].GetCell(fieldx))

lblBidCompletedBy.Text = ("Bid Completed By: " + BidCompletedBy);
0
Comment
Question by:manukaucouncil
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
dbritt earned 2000 total points
ID: 16558914
you're comparing the adjust_field with an incremented index from the corresponding adjust id.

do this instead:

fieldx = 1
do {
adjustid = (ActiveDocument.Sections["R_atm_adjustment"].Columns["Adjust Id"].GetCell(1) + 'a20');
  BidCompletedBy = ActiveDocument.Sections["R_atm_field_data"].Columns["Line Text"].GetCell(fieldx)
}
while ((adjustid) != ActiveDocument.Sections["R_atm_field_data"].Columns["adjust_field"].GetCell(fieldx++))

lblBidCompletedBy.Text = ("Bid Completed By: " + BidCompletedBy);


The ++ operator after fieldx in your while() will increment it AFTER it has been used to access the cell, thus keeping the indecies consistent.

Enjoy!
0
 

Author Comment

by:manukaucouncil
ID: 16558980
Wow that works great. Thanks for that!
0
 
LVL 15

Expert Comment

by:dbritt
ID: 16558988
any time ;)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question