Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript getElementById and Masterpages

Status
Not open for further replies.

AndyH1

Programmer
Jan 11, 2004
350
GB
I'm tying to access a field in the content area of a masterpage with

function showhide(id) {
var x = alert(document.getElementById(id));
document.getElementById(id).style.visibility = 'visible';
}

to set it to visible if a tickbox is ticked

However document.getElementById(id) just seems to be coming out as null when I pass the id of the field 'txtJustification',

chkVPN.Attributes.Add("onclick","showHide('txtJustification')")

I have also tried passing the client id in asp.net
ie

chkVPN.Attributes.Add("onclick", "showHide('" + txtJustification.ClientID + "')")

but this doesn't help either

and tried
parent.document.getElementById

Frankly I'm a bit stuck and I'd appreciate any pointers if anyone can help please. I assume its due to using masterpage, though I'm also using a multiview (as cross page submitting PostBackUrl screws up with masterpages too)

Thanks
Andy

The page content is
...
<asp:Content ID="Content2" ContentPlaceHolderID="pageBody" Runat="Server">
<form id="frmOrderDetails" action="pcCheckout.aspx" method="post">
<asp:MultiView id="MultiView" runat="server" ActiveViewIndex="0">
<asp:textbox id="txtJustification" runat="server" Width="280px" TextMode="MultiLine" Height="88px" CssClass="RequiredField">
...
 
Sorry (looking red faced) - please ignore this. it was a typo in my code and nothing else
Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top