473,379 Members | 1,252 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Get values of text boxes in function

129 100+
Hello friends,
I have one critical doubt on textboxes. That is, I am using modperl and in that within one loop i am giving nof.of text boxes with different names like below:

Expand|Select|Wrap|Line Numbers
  1. foreach $W($week1,$week2,$week3,$week4,$week5,$week6,$week7)
  2. {
  3.     print "<td align=center><input type='text'  name='$code-$testdate'  id='reg_box_parent' value='$shcode' size=3  onkeyup='func(this.form,this.name)'  maxlength=8>";
  4. }
  5.  
The javascript function func code is
Expand|Select|Wrap|Line Numbers
  1. function func(frm,nam)
  2. {
  3.     alert(nam);
  4.     var txt = document.frm.nam.value;
  5.     alert(txt);
  6. }
  7.  
So here, i am getting nam alert but that value i am not getting.
For example, in the loop i am displaying 7 textboxes at a time and those having 7 different names like 3147217-2008-03-16,3147217-2008-03-17,3147217-2008-03-18,
3147217-2008-03-19,3147217-2008-03-20,3147217-2008-03-21,
3147217-2008-03-22
But how to get the values of those textboxes in the function.
Apr 22 '08 #1
2 1152
acoder
16,027 Expert Mod 8TB
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

Also remember to provide a meaningful title for any threads started (see the FAQ entry Use a Good Thread Title).

Moderator.
Apr 22 '08 #2
acoder
16,027 Expert Mod 8TB
Since you're already passing the actual form object, use it. Also use the form elements array to refer to the textbox using the nam string:
Expand|Select|Wrap|Line Numbers
  1. function func(frm,nam)
  2. {
  3.     //alert(nam);
  4.     var txt = frm.elements[nam].value;
  5.     alert(txt);
  6. }
Better still, just pass the actual textbox object instead of the name:
Expand|Select|Wrap|Line Numbers
  1. print "<td align=center><input type='text'  name='$code-$testdate'  id='reg_box_parent' value='$shcode' size=3  onkeyup='func(this)'  maxlength=8>";
Expand|Select|Wrap|Line Numbers
  1. function func(obj)
  2. {
  3.     var txt = obj.value;
  4.     alert(txt);
  5. }
Apr 22 '08 #3

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

Similar topics

2
by: Tom Fitzgibbon | last post by:
Stupid question: How do I loop through many text boxes on a page and get values for each box and put into an array? For example document.CreateEvent.test1.value will not take an array value...
1
by: Frank | last post by:
I have a large form, that has text boxes of numbers in rows and columns. I need to sum the values in the columns, and put the total at the bottom of the column. But I also need to sum the values in...
7
by: Gertjan van Heijst | last post by:
Hi, I really hope someone can help me because I've already spend 2 days on this problem and I'm not getting anywhere. I think the problem is that I don't really understand how text boxes store...
1
by: Richard Hollenbeck | last post by:
I noticed I can't push a value into a text box by saying something like, "txtThisTextBox = intSomeVariable * 0.5" because I get an run-time error saying I can't assign a value to this object....
3
by: ChadDiesel | last post by:
I'm new to Access and need some advice. I am trying to setup a database to print labels and reports for our shipments. I have set up a table with fields such as I have taken a snapshot of what...
1
by: ChadDiesel | last post by:
I'm new to access and need some help. I have a form with a shipment destination at the top. I then have a subform that I enter boxes for that shipment. I have several shipments going at a...
2
by: jackson2005 | last post by:
OK, I need to do three different things. On the ONLOAD event I would like a popup box to open. In this popup box I need two text boxes. One for the UserName and one for the BillingTo name. ...
5
by: kosta.triantafillou | last post by:
Hi all, I have a form that contains a lot of values. On this form there are also alot of popups that can be brought up. One of them does the following: Takes 2 values (x and y), concatenates...
15
by: fanchun | last post by:
I already built 2 javacript files factor.js and parm.js. factor.js is an array, having several factor as elements. for example, factor.js looks like: var factor= parm.js is also an array, having...
12
Dheeraj Joshi
by: Dheeraj Joshi | last post by:
Hi i have a problem. I have 7 text boxex with different id's. I want to run a script via AJAX and i want to populate the result of the script in to these text boxes. The code is function...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.