Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesJavascript to hide controlJavascript to hide control
Previous
 
Next
New Post
8/10/2011 7:34 AM
 
Hi,

I am trying to get some Java script to work on a page to show/hide a textbox control depending on the selection of a dropdown.  I have done this before but I cannot get it to work inside of my DNN code

The Javascript runs and i get into the correct path of the code but it will not reference the field and hide / show it.

Microsoft JScript runtime error: 'document.getElementsByTagName(...).style' is null or not an object

I get the above error when this line of code is run

document.getElementsByTagName('chkLeft').style.display='none';

I have tried it with style.visibility = 'visible' and style.

I have tried
var o = document.getElementsByTagName('chkLeft')[0]
o.style.display = 'none';
and it get the same error on the 2nd line

The control i am trying to reference in my page looks like this
<td align="left" class="style2">
<asp:DropDownList ID="cboRoute" runat="server" Style="z-index: 100" Font-Size="X-Small"
 Width="245px" AutoPostBack="False" Height="16px" onChange=" leftright(this.value);">
</asp:DropDownList>
<asp:CheckBox ID="chkLeft" runat="server" Text="Left" Font-Size="X-Small" Visible="False" />
<asp:CheckBox ID="chkRight" runat="server" Text="Right" Font-Size="X-Small" Visible="False" />
</td>

Any ideas would be appreciated.



 
New Post
8/10/2011 7:15 PM
 
asp.net server controls do not preserve their short names, as asp.net will expand them based on naming containers - as such you need to target their id via server code e.g. document.getElementsByTagName('<%chkLeft.ClientID%>').style.display='none';

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
8/10/2011 9:27 PM
 
Thanks for the explination. I put the code in that you suggested and now i get a different error

Error 12 Property access must assign to the property or use its value.

and the page will not even compile and run any longer, if i remove the line from the page it run again just fine ???

not sure what to make of it

document.getElementsById('<%chkLeft.ClientID%>').style.display = 'none';

this is the line i just removed
 
New Post
8/11/2011 5:05 AM
 
whoops, sorry forgot an equals sign(you need to write out the value with either a Response.Write or else the shorthand =) i.e. <%=chkLeft.ClientID%>

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
8/11/2011 7:26 AM
 
Thanks for the update, that works to get me the control name at runtime.

Now i am still back to the same first error. This is what get rendered in the [dynamic] version of the form

document.getElementsByTagName('dnn_ctr387_frmAddEditPatDrugMaster_pnlLeftRight').style.display = 'inline';

I have tried to set the style.display of the checkbox and now have also tried with a simple panel and still get the same original error.

Microsoft JScript runtime error: 'document.getElementsByTagName(...).style' is null or not an object

Thanks for any additional help.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesJavascript to hide controlJavascript to hide control


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out