Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 05-04-2013, 11:59 PM   #1
Registered: Aug 2004
Distribution: Fedora, Debian
Posts: 355

Rep: Reputation: 30
howto JavaScript take HTML input variable -- continuous

Please copy & paste the following code (it is SOME text input)

My trouble was cannot take document.table1.aX.value where X is something~
<script language="javascript">

function sum(X)
alert( "sum =  " + (parseInt(document.table1.aX.value)+parseInt(document.table1.bX.value))  ) ;
return true


<form name="table1">
<input name="a1" type="text" /><input name="b1" disabled="disabled" value="1" type="text" /><input onclick="sum(1);" value="a1+b1" type="button" /><br />
<input name="a2" type="text" /><input name="b2" disabled="disabled" value="2" type="text" /><input onclick="sum(2);" value="a2+b2" type="button" /><br />
<input name="a3" type="text" /><input name="b3" disabled="disabled" value="3" type="text" /><input onclick="sum(3);" value="a3+b3" type="button" />

I try to explain the design, each row doing the same thing: SUM of text input.

I would like to have a JavaScript function / module
for MANY rowS.

So the JavaScript function has 1 input parameter to tell which row.

Last edited by fhleung; 05-05-2013 at 12:26 AM.
Old 05-05-2013, 02:50 AM   #2
LQ Newbie
Registered: May 2013
Posts: 1

Rep: Reputation: Disabled
JavaScript does not allow call by reference parameters so you can't do
and expect X to represent the value. Instead it represents an element named "aX"

Accept my proposal
Old 07-27-2014, 07:58 PM   #3
Registered: Aug 2004
Distribution: Fedora, Debian
Posts: 355

Original Poster
Rep: Reputation: 30
JavaScript can do much job at client side, IF I got a text file AT CLIENT side machine, I mean the file is NOT at web server but at user machine, I would like to open the file by browser WITHOUT network

another JS question, can anyone show me reference link on howto:
open .txt text file in JavaScript please?

Last edited by fhleung; 07-27-2014 at 08:07 PM.
Old 07-27-2014, 08:14 PM   #4
Senior Member
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,710

Rep: Reputation: 1454Reputation: 1454Reputation: 1454Reputation: 1454Reputation: 1454Reputation: 1454Reputation: 1454Reputation: 1454Reputation: 1454Reputation: 1454
Use a FileReader.
Old 07-27-2014, 11:50 PM   #5
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,789

Rep: Reputation: 497Reputation: 497Reputation: 497Reputation: 497Reputation: 497
You shouldn't reuse old topics though.
Old 08-02-2014, 03:47 AM   #6
Registered: Aug 2004
Distribution: Fedora, Debian
Posts: 355

Original Poster
Rep: Reputation: 30
Assume that having NO networking, NO internet...
Can I using a browser to open/read a file? like .txt file type or any other file type?

Well, I know I can open file(s) by click
File -> open -> browse the file(s) in directory inside harddisk

Answer: following link:

Last edited by fhleung; 08-02-2014 at 04:12 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
howto JavaScript take HTML input variable fhleung Programming 2 05-06-2013 11:55 PM
problem while comparing awk field variable with input variable entered using keyboard vinay007 Programming 12 08-23-2011 12:44 AM
javascript html select sudif Programming 1 04-22-2008 12:18 AM
Javascript & HTML Tux-O-Matic Programming 1 12-07-2006 05:32 PM
Html Javascript help apt Programming 3 03-20-2005 11:46 PM

All times are GMT -5. The time now is 05:41 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration