473,785 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading a Delimited File & Displaying Specific Output on Web Page

I am trying to pull specific data that is in a comma delimited file
into a web page. So if my comma delimited file looks like:

Name,Address,Zi p
Fred,123 Elm,66666
Mike,23 Jump,11111

I would like to be able to read this data and put each row into a
variable? so I could display the values in a web page where I want.

I've seen code to pull the entire set of data into a recordset and then
display the same entire set of data in a web page, but I want to
display specific rows of data. The code I was looking at was this ...
not sure if there is another step here where I can select the data I
want.

<OBJECT ID="data" CLASSID="CLSID: 333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME="DataURL" VALUE="data.txt ">
<PARAM NAME="UseHeader " VALUE="TRUE">
<PARAM NAME="FieldDeli m" VALUE=",">
</OBJECT>

<SCRIPT LANGUAGE="JavaS cript">
/* Get the complete data record set */
var dataSet=data.re cordset;
dataset.moveFir st();
</SCRIPT>

<SPAN DATASRC="#data" DATAFLD="name"> </SPAN>

<SPAN DATASRC="#data" DATAFLD="addres s"></SPAN>

<SPAN DATASRC="#data" DATAFLD="zip"></SPAN>

<P>

Mar 11 '06 #1
1 2590
Jim
Henry,
Here's something I created which may help you. It allows you to create
a txt file on your server, then import it to the web page into an
iFrame which remains out of view. The script below then accesses the
innerHTML of that hidden iFrame to populate your document form. Every
time you chang the customer.txt file on your server, the data imported
will likewise change. Copy and paste the code below into an html file
(don't forget to create the customer.txt file with the test data
supplied) and it will work in msie & firefox:

<head><title>Im port Customer List</title>
<script type="text/javascript">
/*
create a text file with your customer info using commas as delimiters.
Here's the info I made for testing in a customer.txt file:
(customer id number is the first item)
123aa,John Doe,Acme Medical Distributing, 123 Anystreet Lane, AnyTown,
CA,95112,jo**** **@blah.com,905-234-5678,408-123-4567
456bb,Jane Doe,Acme Medical Distributing, 456 Anystreet Lane, AnyTown,
CA,95112,jo**** **@blah.com,905-234-5678,408-123-4567
789cc,Jerry Doe,Acme Medical Distributing, 789 Anystreet Lane, AnyTown,
CA,95112,jo**** **@blah.com,905-234-5678,408-123-4567
*/
/* COMMENT: iframe source file content must be accessed
// cross browser by obtaining the innerHTML of the
// iframe source. When that content is obtained, it is
// interpreted by the browser which may insert <pre or
// other tags into the result. This function htmlEscape will
// take out the <pre and </pre tags from that character string.
*/
function htmlEscape(s){
s=s.replace(/\//g,'');
s=s.replace(/>/g,'');
s=s.replace(/</g,'');
s=s.replace(/pre/gi,'');
return s;
}

// pass unique customer number to script to obtain just the string of
info for that customer which is inside the iframe content

function getCust(cusno){
this.cusno =cusno;
var custno = cusno.toString( );
// iframe containing customer.txt is named "customer" :
var fsc = window.frames['customer'].document.body. innerHTML;

var file_stringc=ht mlEscape(fsc);
var btc = file_stringc.sp lit("\n");
var len= btc.length;
var customer_detail s, contact, company_name, addy1, addy2, city,
province, postal_code, email, phone, fax;
for(i=0; i<len; i++){
customer_detail s = btc[i];
cd = customer_detail s;
//extract the first 5 digits of the string which is the customer id:
// note that if you change the length of the customer id, you need to
change how
// variable 'matcher' is created ie: cd.substring(0, [length])
var matcher = cd.substring(0, 5);
//find the matching string with the customer number passed
in the parameter:
if(custno == matcher){
//populate an array with the contents of that matched string of
customer info:
c_details =cd.split(",");
//iterate through the array to assign values to variables matching
your form name:
customer_number =c_details[0];
contact =c_details[1];
company_name =c_details[2];
addy1 =c_details[3];
addy2= c_details[4];
city =c_details[5];
postal_code =c_details[6];
email =c_details[7];
phone = c_details[8];
fax = c_details[9];
}
}
// populate the form using the variables above:
document.forms["orderform"].elements['contact_name'].value =contact;
document.forms["orderform"].elements['company_name'].value =
company_name;
document.forms["orderform"].elements['addy1'].value = addy1;
document.forms["orderform"].elements['addy2'].value = addy2;
document.forms["orderform"].elements['city'].value = city;
document.forms["orderform"].elements['postal_code'].value =
postal_code;
document.forms["orderform"].elements['email'].value = email;
document.forms["orderform"].elements['phone'].value = phone;
document.forms["orderform"].elements['fax'].value = fax;

}
</script>
</head>
<body>
<h4>This is the iFrame which imports customer.txt from your server. In
the original script, i set its style to be left:-2500; top:-2500;

width:0px; height:0px so that it is hidden from view on the document,
yet still accessible from the script</h4>
<hr/>
<iframe name="customer" id="customerfra me" src="customer.t xt"
width="90%" height="120px" border="3px"></iframe>
<hr/>
<h4>
Scroll through the iframe text and select the first 5-digit number (eg:
123aa, 456bb, 789cc) and input that number into the box

labelled Customer Number. Hit your tab key to trigger the onBlur event
which pulls in the appropriate information and populates

the rest of the form with the correct data.
</h4>
<form method="POST" name="orderform " action="">
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#1 11111" width="74%"

id="AutoNumber1 ">
<tr>
<td width="12%" height="13">Cus tomer #</td>
<td width="36%" colspan="3" height="13">
<input type="text" name="customer_ no" size="19" style="font-size:
8pt" onBlur="getCust ( this.value)"></td>
<td width="13%" height="13"></td>
<td width="26%" colspan="2" height="13"><u> <b>PURCHASE
ORDER</b></u></td>
<td width="13%" height="13"></td>
</tr>
<tr>
<td width="12%" height="1">Cont act Name</td>
<td width="36%" colspan="3" height="1">
<input type="text" name="contact_n ame" size="49"
style="font-size: 8pt"></td>
<td width="26%" colspan="2" height="1"><fon t SIZE="2">
<p ALIGN="CENTER"> <b>To be filled by:</b></font></td>
<td width="13%" height="1"></td>
<td width="13%" height="1"></td>
</tr>
<tr>
<td width="12%" height="1">Comp any Name</td>
<td width="36%" colspan="3" height="1">
<input type="text" name="company_n ame" size="49"
style="font-size: 8pt"></td>
<td width="13%" height="1"></td>
<td width="39%" colspan="3" rowspan="2" height="1">
<font size="6" face="Century Gothic">Your Company
Name</font></td>
</tr>
<tr>
<td width="12%" height="1">Addr ess Line 1</td>
<td width="36%" colspan="3" height="1">
<input type="text" name="addy1" size="49" style="font-size:
8pt"></td>
<td width="13%" height="1"></td>
</tr>
<tr>
<td width="12%" height="1">Addr ess Line 2</td>
<td width="36%" colspan="3" height="1">
<input type="text" name="addy2" size="49" style="font-size:
8pt"></td>
<td width="13%" height="1"></td>
<td width="39%" colspan="3" height="1"><fon t SIZE="1">Your
Company Address</font></td>
</tr>
<tr>
<td width="12%" height="1">City </td>
<td width="36%" colspan="3" height="1">
<input type="text" name="city" size="49" style="font-size:
8pt"></td>
<td width="13%" height="1"></td>
<td width="39%" colspan="3" height="1"><fon t SIZE="1">YourCo
City, State Here</font></td>
</tr>
<tr>
<td width="12%" height="1">Prov ince</td>
<td width="36%" colspan="3" height="1">
<input type="text" name="province" size="35" style="font-size:
8pt"></td>
<td width="13%" height="1"></td>
<td width="39%" colspan="3" height="1"><fon t size="1">Your Co.
Zip Code</font></td>
</tr>
<tr>
<td width="12%" height="1">Post al Code</td>
<td width="36%" colspan="3" height="1">
<input type="text" name="postal_co de" size="25" style="font-size:
8pt"></td>
<td width="13%" height="1"></td>
<td width="13%" height="1"></td>
<td width="13%" height="1"></td>
<td width="13%" height="1"></td>
</tr>
<tr>
<td width="12%" height="11">Con tact Email</td>
<td width="36%" colspan="3" height="11">
<input type="text" name="email" size="49" style="font-size:
8pt"></td>
<td width="13%" height="11"></td>
<td width="13%" height="11"></td>
<td width="13%" height="11"></td>
<td width="13%" height="11"></td>
</tr>
<tr>
<td width="12%" height="4">Cont act Phone</td>
<td width="36%" colspan="3" height="4">
<input type="text" name="phone" size="30" style="font-size:
8pt"></td>
<td width="13%" height="4"></td>
<td width="13%" height="4"></td>
<td width="13%" height="4"></td>
<td width="13%" height="4"></td>
</tr>
<tr>
<td width="12%" height="5">Cont act Fax</td>
<td width="36%" colspan="3" height="5">
<input type="text" name="fax" size="30" style="font-size:
8pt"></td>
<td width="13%" height="5"></td>
<td width="13%" height="5"></td>
<td width="13%" height="5"></td>
<td width="13%" height="5"></td>
</tr>
</table>
</body>

Mar 11 '06 #2

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

Similar topics

7
7100
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and disadvantages of using a MySQL blob field rather than reading the images directly from the file? How does one insert an image into a blob field? Can it be done dynamically? Thank you John
3
21849
by: TF | last post by:
Hi, I have to access data from a comma delimited file in .net windows application (VB.net or C#). I am using Microsoft.Jet.OLEDB.4.0 provider for this purpose. Now the problem is when i extract data from a file with extension csv or txt it works fine but as soon as i change the extension, like 'log' or 'abc' it gives following error in 'Fill' function of 'OleDbDataAdapter': Cannot update. Database or object is read-only
8
18253
by: Phil Slater | last post by:
I'm trying to process a collection of text files, reading word by word. The program run hangs whenever it encounters a word with an accented letter (like rôle or passé) - ie something that's not a "char" with an ASCII code in 0..127 I've searched the ANSI C++ standard, the internet and various text books, but can't see how to workaround this one. I've tried wchar_t and wstring without success. But rather than spending lots of time on...
5
2719
by: Yama | last post by:
Hi, I am looking to create a report comma delimited on a click of a button. Explanantion: 1. Get from the database: "SELECT * FROM Customers WHERE Region = 'CA'" 2. Use either DataReader or DataSource 3. Create a button "Export" 4. On ServerClick Event prompt user to save as a text comma delimited file.
9
6789
by: jeff M via .NET 247 | last post by:
I'm still having problems reading EBCDIC files. Currently itlooks like the lower range (0 to 127) is working. I have triedthe following code pages 20284, 20924, 1140, 37, 500 and 20127.By working I get the correct answer by taking the decimal valueand using that as an index to an array that will map to thecorrect EBCDIC value in hex. By larger values, an example would be "AA" in EBCDIC hex wouldgive me the value of 63 in decimal (ASCII) when...
5
12309
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. On Beta1, I am able to execute a particular page with no problem, that page opens up in the comes up just fine. On Win2kdev1, when I go to execute the same page, it opens a file download dialog and asks me whether I want to open or save the...
13
2901
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or GET). I got Application.FollowHyperlink *kind* of working, but was having problem with double encoding of some characters (I had to do special things with + signs in the data, as well as never figuring out why some data was getting...
1
7816
jwwicks
by: jwwicks | last post by:
Hello All, This is a student assignment. So I don't want the complete answer just a hint or maybe a bumb on the head cause I'm doing it the wrong way. Assume I haven't done anything braindead like not include a header etc... I can post the whole code if you like/need it but I'm trying to spare the forum :) Got a product structure... struct product { string id; string description; int quantity;
7
3337
by: kimmelsd33 | last post by:
I am using VB6. I want to read a tab delimited file, and assign each column value into a variable. If the variable is "-999.25", I want to make it a "0". I then want to reassemble the values, and write them to a temp text file. Starting with line 64, I have about 28 columns and x number of rows. Ex: 1000<tab>23.3<tab>-999.25<tab> etc. The value of -999.25 can be in any column. I need to replace it before it is stored in the variable. I need to...
0
9647
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
9485
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
10356
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
10098
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
9958
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
8986
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
7506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2890
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.