access web controls in a User control via Javascript

G

george d lake

Hi,
I have a user control that has a series of web controls in it.
I need to access the web controls from the parent page via javascript. No, I
have done this in the past but know I am having problems. It just will not
find the obj on the javascript side.

here is some code (HTML output):


<span id="ucUntouchedItems_spUntouched" style="CURSOR:hand;COLOR:#003399"
onClick="toggleBB(ucUntouchedItems_divUntouched,
ucUntouchedItems_imgUntouched,ucUntouchedItems_htbUntouched)">
<img id="ucUntouchedItems_imgUntouched"
src="/TicketSystemV2/images/collapse.gif" border="0"
style="border-style:None;height:16px;width:16px;" />
<span id="ucUntouchedItems_lbGridName">Untouched Items (4)</span><br>
</span>
<input id="ucUntouchedItems_htbUntouched" type="hidden" />
<div id="ucUntouchedItems_divUntouched" style="DISPLAY:none">

If I run at the buttom of the page:

<script language=javascript>
alert(ucUntouchedItems_htbUntouched);
alert(ucUntouchedItems_imgUntouched);
alert(ucUntouchedItems_divUntouched);
</script>

I get Errors on the first 2.

Any ideas why? I am missing something???
 
C

Chris Jackson

You may want to try document.getElementByID(...) to get a reference to that
object, and then grab the value attribute of that object. ie:

var htbUntouched = document.getElementByID("ucUntouchedItems_htbUntouched");
if (htbUntouched != null) {
window.alert(htbUntouched.value);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top