473,382 Members | 1,368 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,382 software developers and data experts.

looking at each element in the form

I have this large form with over 150 elements. I need to do some
formatting of the data in some of the fields. I do this based on the
name of the fields, i.e the field names would be
cost1,cost2, cost 3, cost 4 .... you get the picture

for ( var i=0;i<document.update.elements.length;i++ )
{
if ( document.update.elements[i].type=="text" )
{
if ( document.update.elements[i].name.substr(0,4)=="COST" )

{
currencyPaste(document.update.elements[i]);
}
}
}

Is there another way I can zero in of just these field to update without
enumerating over each element in the form?

Jul 20 '05 #1
2 14303
On Wed, 08 Oct 2003 12:25:07 -0500, Michael Hill
<hi****@ram.lmtas.lmco.com> wrote:
I have this large form with over 150 elements. I need to do some
formatting of the data in some of the fields. I do this based on the
name of the fields, i.e the field names would be
cost1,cost2, cost 3, cost 4 .... you get the picture

for ( var i=0;i<document.update.elements.length;i++ )
{
if ( document.update.elements[i].type=="text" )
{
if ( document.update.elements[i].name.substr(0,4)=="COST" )

{
currencyPaste(document.update.elements[i]);
}
}
}

Is there another way I can zero in of just these field to update without
enumerating over each element in the form?


Assuming they are all numbered consequtively...

var i = 1;
var element = documnet.update.elements["cost" + i];
while (element != null)
{
currencyPaste(element);
i++;
element = document.update.elements["cost" + i];
}

Regards,
Steve
Jul 20 '05 #2
Steve thanks,

That will work nicely.

Mike
"Steve van Dongen" <st*****@hotmail.com> wrote in message
news:s7********************************@4ax.com...
On Wed, 08 Oct 2003 12:25:07 -0500, Michael Hill
<hi****@ram.lmtas.lmco.com> wrote:
I have this large form with over 150 elements. I need to do some
formatting of the data in some of the fields. I do this based on the
name of the fields, i.e the field names would be
cost1,cost2, cost 3, cost 4 .... you get the picture

for ( var i=0;i<document.update.elements.length;i++ )
{
if ( document.update.elements[i].type=="text" )
{
if ( document.update.elements[i].name.substr(0,4)=="COST" )

{
currencyPaste(document.update.elements[i]);
}
}
}

Is there another way I can zero in of just these field to update without
enumerating over each element in the form?


Assuming they are all numbered consequtively...

var i = 1;
var element = documnet.update.elements["cost" + i];
while (element != null)
{
currencyPaste(element);
i++;
element = document.update.elements["cost" + i];
}

Regards,
Steve

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Frank Einstein | last post by:
Looking for a tool that can edit an XML file in a browser. The basic requirement is that the XML file is rendered as an HTML form with editable fields (including add/delete, preferably in...
4
by: George Hester | last post by:
I have a form that has 4 <INPUT> elements in it each with a unique id. The page loads with the <INPUT> id = 1 with focus. If a tab is done immediately without entering anything in this INPUT text...
2
by: David Pautler | last post by:
I'm creating a web-based authoring tool where one form encompasses several sections for editing. I'd like each section to have its own reset button, so that use of that button affects only that...
5
by: hiroshi ochi | last post by:
Hello, Using MSIE 6.0 and above, with javascript is it possible to display an individual tooltip for each item in a listbox? I need this functionality to show the listitems that are longer...
4
by: Wayne Wengert | last post by:
I am looking for pointers to good beginner books, tutorials or other resources to help me understand how to really use XML data. I program mostly in VB (I have several applications in VB6 but am...
11
by: admin | last post by:
Hi all, First time poster here... I'm a webmaster and I'd like to add a simple script to my website which will allow users to fill in a brief multiple choice questionaire, and then provide a...
7
by: Bruce HS | last post by:
I'd like to call my ancestor Validation Function every time any control on a Win Form generates a Validating or Validated event. I'm using VB. I've extended Textbox, for instance, to have its...
0
by: AMDRIT | last post by:
I am looking for better concrete examples, as I am a bit dense, on design patterns that facilitate my goals. I have been out to the code project, planet source code, and microsoft's patterns and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.