Need Help With Array Of Controls in Javascript

krishnandu

Skilled
Hey friends, I'm badly stuck on a part in JavaScript.

The case is, I've array of text box controls say txtrate[].

Now I want to access particular text box, say txtrate[0] or txtrate[1] so on..

I'm attaching a screenshot for better understanding...


Uploaded with ImageShack.us

The thing I want to actually achieve is, when someone select particulars, I'll be fetching it's quantity using AJAX and put in Quantity list. So as you can understand, I need to access each one of the controls because for each item in particulars will have diff. quantity. I've already done the Ajax part, but can't put it in quantity box as I can't access particular control from the array of controls.

BTW I must mention that I can access non array controls, I've tried that.

And I've already tried with txtrate[0], txtrate[1] etc. , txtrate, txtrate[], nothing is working. Please help.

--- Updated Post - Automerged ---

EDIT : Ok guys got the solution.

Posting it for future reference.

When we do document.getElementById('txtsomething[]'), it returns the whole control array.

So we need to follow...

x = document.getElementById('txtsomething[]');

x[0].value = "Something";

in this way. :)

Hope it helps other member who came searching for the same in future.
 
Back
Top