|
-
Nov 17th, 2004, 10:07 AM
#1
Thread Starter
Frenzied Member
Resolved - Check ListBox for selection
I have rows in a table that are populated from a database.
The first field is a textbox called txtRank, this is where the user enters the rank for this particular item.
If the rank is greater than 0, then a listbox appears (named cboEnhancement_<GUIDFROMDATABASE>) and the user must select at least one item from the listbox.
What I need to do in javascript is loop through all of the txtRank elements, if they have a value greater than 0, then I need to check the cboEnhancement listbox for this row to make sure they have selected at least one option.
Here's what I have so far, it works but I just don't know how to check the associated listboxes selections.
Code:
function CheckRankAndVersions()
{
// If the rank is greater than 0, then make sure they
// have selected a version for the enhancement
for (i=0; i<document.forms[0].elements.length; i++)
{
if(document.forms[0].elements[i].name == "txtPriority")
{
if(document.forms[0].elements[i].value > 0)
{
//This gets the value of the txtRank textbox
alert("Greater than 0: " + document.forms[0].elements[i].value);
//Need to check the listboxes selections here
}
}
}
}
I'm just a little confused how to associate a particular row txtRank with the same rows cboEnhancement listbox.
Any ideas how this can be done?
BTW, rewriting this isn't an option, this is just a small part of a large application.
Last edited by Memnoch1207; Nov 18th, 2004 at 11:05 PM.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Nov 18th, 2004, 05:52 AM
#2
Well, you're guaranteed, I think, that form elements are added in source order to the elements array. Thus you should be able to calculate an offset in the elements array.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|