LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 05-05-2013, 12:59 AM   #1
fhleung
Member
 
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~
Code:
<script language="javascript">

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

</script>


<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" />
</form>

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 01:26 AM.
 
Old 05-05-2013, 03:50 AM   #2
awesomeousPrime
LQ Newbie
 
Registered: May 2013
Posts: 1

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



Accept my proposal
 
Old 07-27-2014, 08:58 PM   #3
fhleung
Member
 
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 09:07 PM.
 
Old 07-27-2014, 09:14 PM   #4
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,976

Rep: Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555Reputation: 1555
Use a FileReader.

https://developer.mozilla.org/en-US/...b_applications
 
Old 07-28-2014, 12:50 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,927

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
You shouldn't reuse old topics though.
 
Old 08-02-2014, 04:47 AM   #6
fhleung
Member
 
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:
http://stackoverflow.com/questions/1...-in-javascript
http://stackoverflow.com/questions/1...ocal-text-file

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


Reply


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-07-2013 12:55 AM
problem while comparing awk field variable with input variable entered using keyboard vinay007 Programming 12 08-23-2011 01:44 AM
javascript html select sudif Programming 1 04-22-2008 01:18 AM
Javascript & HTML Tux-O-Matic Programming 1 12-07-2006 06:32 PM
Html Javascript help apt Programming 3 03-21-2005 12:46 AM


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

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