Hello!
Im having a hard time figuring out a loop that would check specific dropdown fields in a form and change their text color based on the dropdowns selectedIndex or rawValue.
Could someone please post a sample script?
Thanks in advance!
Views
Replies
Total Likes
Yes, you can do that, but specific dropdowns here means what? Any speific name given or something else?
Views
Replies
Total Likes
Yes, they have specific names. I ment that, for example, I have a form with 3 dropdown fields, but I want to loop just 2 of them.
Views
Replies
Total Likes
Try this .
var nodeLength = Page1.nodes.length; // Counts the total nodes present in the page
var thisElement;
for (var i=0; i<nodeLength; i++) { // loops through all the nodes
thisElement = Page1.nodes.item(i); // add the items
if (thisElement.className == "field"){ // DropDown is a field so it checks for that
if (thisElement.name == "Your DDL Name"){ // Checks your DDL name
//somecode;
}
}
Thanks,
Bibhu.
Views
Replies
Total Likes
Thanks, it kinda works, but it is not quite what Im looking for. The DDL have diferent names
so I should have to put if statements for all those DDL, which would make the loop pointless.
My idea was to put all the dropdowns in an array and then loop them and check there values
something like:
var t = 0
var fields = [ DropDown1, DropDown2, DropDown3, DropDown4 ]
for (var i = 0; i<fields.lenght; i++)
{
if (Dropdown.selectedIndex == "0")
{
t =t++
}
}
The problem is that i dont know how to write code for the if statement that checks the selectedIndex.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies