Link to home
Start Free TrialLog in
Avatar of ChiBella
ChiBella

asked on

Javascript getElementById for text within a placeholder?

Can anyone tell me the syntax for accessing a textbox that exists within a placeholder within a javascript function?

var iOldDispoQuantity = parseInt(document.getElementById('tbOldDispoQuantity'));
var iQuantityAvai = parseInt(document.getElementById('tbQuantityAvailable'));

I'm getting "NaN" errors and I think it's because the two textboxes are within a placeholder (child of a masterpage).
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ChiBella
ChiBella

ASKER

var iOldDispoQuantity = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbDispoQuantity'));
var iQuantityAvai = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbQuantityAvailable'));


also tried the name and get same "NaN" error.

any other suggestions?
what about this:

var iOldDispoQuantity = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbDispoQuantity').value);
var iQuantityAvai = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbQuantityAvailable').value);
var iOldDispoQuantity = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbDispoQuantity').Value);
var iQuantityAvai = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbQuantityAvailable').Value);


same thing... "NaN"
case matters

use lowercase value like i typed it, not Value
I had the case wrong on value. It works!

Thanks again!
no problemo
I have one more problem. One of the text fields I'm pulling is not visible....so generates an error. Is there a workaround for this?
hi chibella, you should accept an answer on this question and then post a new question for the new issue.
oh man...you are trying to become genious!
thanks chibella, did you accept the answer that helped you or just the first one?  I though this one answered your question: 20113427...

This kind of defeats the purpose of EE because people will come her elooking for answers and they will look at which one you selected as the 'accepted answer'.
No I chose the right answer. The question was how to find the right syntax within a placeholder. You did assist some....so I guess you can have 50.
var disposableQuant = document.getElementById('ctl00_ContentPlaceHolder1_tbDispoQuantity');
var quatAvailable = document.getElementById('ctl00_ContentPlaceHolder1_tbQuantityAvailable');
var iOldDispoQuantity = (disposableQuant!=null)?parseInt(disposableQuant.value):0;
var iQuantityAvai = (quatAvailable!=null)?parseInt(quatAvailable.value):0;
I'd like to spread the points. How do I do that after it's closed?
no idea, probably can't

btw, i re-read your question at post 20113504 and think i was wrong to say you should open a new question for it, when i read it i thought it was unrelated (to do with ap.net control visibility) but i see it is actually a tweak to the script in question.  that's why i posted 20115947.