?
Solved

Javascript getElementById for text within a placeholder?

Posted on 2007-10-19
15
Medium Priority
?
481 Views
Last Modified: 2012-05-11
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).
0
Comment
Question by:ChiBella
  • 7
  • 7
15 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 20113379
You need to find the UniqueID for the TextBox controls, by looking at the rendered output with 'View Source' from the browser.

Bob
0
 

Author Comment

by:ChiBella
ID: 20113423
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
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20113427
what about this:

var iOldDispoQuantity = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbDispoQuantity').value);
var iQuantityAvai = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbQuantityAvailable').value);
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ChiBella
ID: 20113436
var iOldDispoQuantity = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbDispoQuantity').Value);
var iQuantityAvai = parseInt(document.getElementById('ctl00_ContentPlaceHolder1_tbQuantityAvailable').Value);


same thing... "NaN"
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20113438
case matters

use lowercase value like i typed it, not Value
0
 

Author Comment

by:ChiBella
ID: 20113439
I had the case wrong on value. It works!

Thanks again!
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20113441
no problemo
0
 

Author Comment

by:ChiBella
ID: 20113504
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
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20113512
hi chibella, you should accept an answer on this question and then post a new question for the new issue.
0
 

Author Comment

by:ChiBella
ID: 20113514
oh man...you are trying to become genious!
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20113527
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
 

Author Comment

by:ChiBella
ID: 20113541
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
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20115947
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
 

Author Comment

by:ChiBella
ID: 20116007
I'd like to spread the points. How do I do that after it's closed?
0
 
LVL 23

Expert Comment

by:basicinstinct
ID: 20117002
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

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question