473,809 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get values of text boxes in function

129 New Member
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 1171
acoder
16,027 Recognized Expert Moderator MVP
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 Recognized Expert Moderator MVP
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
13320
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 for the object name. Tried to figure out if associative arrays might help but failed miserably. Obviously I can name the text boxes anything, but can't get the values out.
1
2289
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 each row, and put the total at the end of the row. What is the javascript to sum the values to a few text boxes, and how would I write the script for these totals to run all at once? Thanks.
7
8669
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 'empty' values. I'm trying tot do the following. I have a continous sub form that lists transactions. On the top level form I have some text boxes to let the user specify the transactions between which dates should be listed. To do this I have...
1
1849
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. So instead I made the control source a function to pull the value from the function. That works. Inside the text box I simply write something like =SomeFunction(). Beautiful. Works great.
3
1700
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 I would like to do: http://www.chadworld.com/images/form.jpg All of these fields are in a table called: Ship_Info
1
2882
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 time, so I can use the control at the bottom of the form to move from shipment to shipment and I can see all the boxes in each shipment. I'd like to put a subtotal for the shipment weight and box types at the bottom of the subform.
2
6964
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. After entering these two items the user can either hit the enter key or press the submit button. The popup window will close and then those two text boxes in the original webpage will be filled in automatically. I would like to have the two...
5
2469
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 them together with an underscore in between and adds them to a select box in the same popup (z). Then, when a user clicks a save button located on the popup, it sends that information back to the main form and populates the same three values (x,...
15
5830
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 coresponding parameters to those factors in factor.js file. it looks like var parm= I want to build an regression formula based on the factors and parameters in these two js file. for example, y= 0.5+x1*0.1+x2*(-0.2)+x3*0+x4*1+x5*0.3 i want to...
12
1903
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 show(id) { id1=id;
0
9602
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
10639
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...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
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...
1
7661
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
6881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.