Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.selected 2

Status
Not open for further replies.

Gatorajc

MIS
Mar 1, 2002
423
0
0
US
How would I go about getting a result like this?

document.OrderItems.ACDV_BillStatus[0].selected = true

The bold part is dynamic. I tried

document.OrderItems.products[pcnt]_BillStatus[0].selected = true;

This is what the function looks like

function ChangeStatus(formname)
{
productlist = formname.productlist.value;
productcount = formname.productcount.value;
productcount = productcount - 1;
products = productlist.split(",");

if (formname.OrderType.value == "ZERR")
{
for (pcnt= 0; pcnt < productcount; pcnt++)
{
document.OrderItems.products[pcnt]_BillStatus[0].selected = true;

}
}
}

I know there is a value in products[pcnt]. Just not sure I would put it together or even if I could do it this way.

AJ
[americanflag]

Do you feel lucky?


 
just use the eval() function, like this:
Code:
function ChangeStatus(formname)
{
productlist = formname.productlist.value;
productcount = formname.productcount.value;
productcount = productcount - 1; 
products = productlist.split(",");

if (formname.OrderType.value == "ZERR")
    {
    for (pcnt= 0; pcnt < productcount; pcnt++)
        {
        [COLOR=red]eval[/color]("document.OrderItems."+products[pcnt]+"_BillStatus[0].selected = true");

        }
    }    
}

hope that helps

"Whether you think that you can, or that you can't, you are usually right." - Henry Ford
 
PERFECT!!!!! Thanks for your help.

AJ
[americanflag]

Do you feel lucky?


 
I think doing it without eval would be a better way, as eval is slow, and should be avoided unless absolutely necessary..

Haven't tested this (you didn't provide form information), but give it a try anyway:

Code:
document.OrderItems[products[pcnt] + '_BillStatus'][0].selected = true;

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top