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).
ChiBellaAsked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
You need to find the UniqueID for the TextBox controls, by looking at the rendered output with 'View Source' from the browser.

Bob
0
 
ChiBellaAuthor Commented:
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?
0
 
basicinstinctCommented:
what about this:

var iOldDispoQuantity = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbDispoQuantity').value);
var iQuantityAvai = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbQuantityAvailable').value);
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
ChiBellaAuthor Commented:
var iOldDispoQuantity = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbDispoQuantity').Value);
var iQuantityAvai = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbQuantityAvailable').Value);


same thing... "NaN"
0
 
basicinstinctCommented:
case matters

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

Thanks again!
0
 
basicinstinctCommented:
no problemo
0
 
ChiBellaAuthor Commented:
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?
0
 
basicinstinctCommented:
hi chibella, you should accept an answer on this question and then post a new question for the new issue.
0
 
ChiBellaAuthor Commented:
oh man...you are trying to become genious!
0
 
basicinstinctCommented:
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'.
0
 
ChiBellaAuthor Commented:
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.
0
 
basicinstinctCommented:
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;
0
 
ChiBellaAuthor Commented:
I'd like to spread the points. How do I do that after it's closed?
0
 
basicinstinctCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.