473,473 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Insert a value from a file in an html page

5 New Member
Hi,
I do not know much about javascript (let alone php), so I will need a little bit more than a lead to help me with this.

What I would like is to be able to read a word (or in this case a real number) from a simple flat text file (or like the old .ini files), or even from a spreadsheet, with the following sort of data -
Expand|Select|Wrap|Line Numbers
  1. a1=27.99
  2. a2=19.99
  3. a3=53.49
  4. c23=8.25
  5. f217=149.99
............etc.
- where the first bit of the line is an identifier, and the second bit is the value needed. (I don't care what delimits the identifier).
Then in the html file, at the position it is needed, have an "insert the value of a3: here" type of statement.

This must have been done before, but I have spent 2 days searching for a similar idea, but to no avail.

My original idea was to have a numbers.js file containing -
Expand|Select|Wrap|Line Numbers
  1. var a1=27.99
  2. var a2=19.99
  3. var a3=53.49
  4. var c23=8.25
  5. var f217=149.99
.............etc.

Then in the html file have a -
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="numbers.js">
  2. document.write (a1)
  3. </script>
in the appropritate position. But it doesn't work.....:(

Can anyone help me please?
Oct 8 '07 #1
5 1661
pbmods
5,821 Recognized Expert Expert
Heya, Aquatic.

Please use CODE tags when posting source code:

[CODE=javascript]
JavaScript code goes here.
[/CODE]
Oct 9 '07 #2
dmjpro
2,476 Top Contributor
Hi,
I do not know much about javascript (let alone php), so I will need a little bit more than a lead to help me with this.

What I would like is to be able to read a word (or in this case a real number) from a simple flat text file (or like the old .ini files), or even from a spreadsheet, with the following sort of data -
Expand|Select|Wrap|Line Numbers
  1. a1=27.99
  2. a2=19.99
  3. a3=53.49
  4. c23=8.25
  5. f217=149.99
............etc.
- where the first bit of the line is an identifier, and the second bit is the value needed. (I don't care what delimits the identifier).
Then in the html file, at the position it is needed, have an "insert the value of a3: here" type of statement.

This must have been done before, but I have spent 2 days searching for a similar idea, but to no avail.

My original idea was to have a numbers.js file containing -
Expand|Select|Wrap|Line Numbers
  1. var a1=27.99
  2. var a2=19.99
  3. var a3=53.49
  4. var c23=8.25
  5. var f217=149.99
.............etc.

Then in the html file have a -
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="numbers.js">
  2. document.write (a1)
  3. </script>
in the appropritate position. But it doesn't work.....:(

Can anyone help me please?
Are you looking for File Operation with JavaScript?
Sorry ...............!
It's not possible with standard JavaScript :-(

Debasis Jana
Oct 9 '07 #3
gits
5,390 Recognized Expert Moderator Expert
hi ...

if it would be a txt-file only you could make an attempt to load it into an iframe (may be even hidden) and then parse it with javascript and fill its values into your webpage ... but: the webpage has to be your own. this could work ... since the browser loads the txt-file like any other document and you may handle it that way ... but it would be a hack or workaround for the fact that you cannot read files with javascript except when they are loaded into the browser and you are able to retrieve its values form a document ...

kind regards
Oct 9 '07 #4
Aquatic
5 New Member
Hi,
I don't really need to do file I/O, I just want the javascript to print out the contents of a specific variable defined in numbers.js own code.
- numbers.js file just contains a bunch of variables:
Expand|Select|Wrap|Line Numbers
  1. var a1=27.99
  2. var a2=19.99
  3. var a3=53.49
  4. var c23=8.25
  5. var f217=149.99
  6. .............etc.
  7.  
Then in the html file where the variables value is needed, have a -
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="numbers.js">
  2. document.write (a1)
  3. </script>
  4.  
Does that make sense ?
Regards,
Oct 9 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
Try changing this:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="numbers.js">
  2. document.write (a1)
  3. </script>
  4.  
to this:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="numbers.js"></script>
  2. <script type="text/javascript">
  3. document.write (a1);
  4. </script>
  5.  
Oct 9 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Polyhedron_12 | last post by:
I am having problems calling functions in general in VB. I keep getting alot of errors. Can anybody help me out with this? I put the error message on the same line that it says it is at. I believe...
1
by: Ed Dror | last post by:
Hi there, I have ASP <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Guestbook.aspx.vb" Inherits="Guestbook" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
0
by: isaac2004 | last post by:
im trying to make a page that reads simple user information and posts them to a table. the user can edit, delete and add new records, through a form on the page.using SQLs modifications like...
0
ak1dnar
by: ak1dnar | last post by:
There is a Error getting while i am entering records using this jsp file. <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ include...
10
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads MyVar=DMax("","MyTable... You can never be...
1
by: deepaks85 | last post by:
Dear Friends, Please help me out where I am doing mistake...I am trying to insert records into my MSSQL database...but it always take me into the "page cannot be displayed"....Here is the code.......
8
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
2
by: vijaykumardahiya | last post by:
Hello Sir, I have a simple Issue but It is not resolve by me i.e input parameter are not store in Ms-Access. I store the input parameter through Standard Action <jsp:useBean>. jsp:useBean call a...
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
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...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.