Javascript Error
-
hi all i have a web page and a gridview inside it. In this gridview i added an item template, inside this item template i have a table called table main. Inside table main, in the last tr i have another table called tblOperator and an html button called btnview so the code looks like: <code> <asp:GridView ID="gvRaison" runat="server" AllowPaging="True" AutoGenerateColumns="False" PageSize="5" ShowHeader="False" Width="100%" DataKeyNames="RaisonId" EmptyDataText="No Data found"> <Columns> <asp:TemplateField HeaderText="Name"> <ItemTemplate> <table style="width: 100%;" Id="TableMain" class="TableMain"> <tr>. <tr> <input id="btnview" type="button" onclick="ShowHideTable(this);" value="Show" /> <table id="tblOperator" class="TableMain" style="width: 70%"> </code> i have wrote a javscript function to view/hide the tbloperator function ShowHideTable(args) { if (args.value=='Show') { tblOperator.style.display="block"; args.value= 'Hide'; } else if (args.value=='Hide') { tblOperator.style.display="none"; args.value= 'Show'; } } iam getting an error on this line tblOperator.style.display="none"; the error says tblOperator.style is null or not an object. how can i reference the tblOperator table and set its display?
-
hi all i have a web page and a gridview inside it. In this gridview i added an item template, inside this item template i have a table called table main. Inside table main, in the last tr i have another table called tblOperator and an html button called btnview so the code looks like: <code> <asp:GridView ID="gvRaison" runat="server" AllowPaging="True" AutoGenerateColumns="False" PageSize="5" ShowHeader="False" Width="100%" DataKeyNames="RaisonId" EmptyDataText="No Data found"> <Columns> <asp:TemplateField HeaderText="Name"> <ItemTemplate> <table style="width: 100%;" Id="TableMain" class="TableMain"> <tr>. <tr> <input id="btnview" type="button" onclick="ShowHideTable(this);" value="Show" /> <table id="tblOperator" class="TableMain" style="width: 70%"> </code> i have wrote a javscript function to view/hide the tbloperator function ShowHideTable(args) { if (args.value=='Show') { tblOperator.style.display="block"; args.value= 'Hide'; } else if (args.value=='Hide') { tblOperator.style.display="none"; args.value= 'Show'; } } iam getting an error on this line tblOperator.style.display="none"; the error says tblOperator.style is null or not an object. how can i reference the tblOperator table and set its display?
var tbl = document.getElementById("tblOperator"); if (tbl) { tbl.style.display = "none"; } I believe that window.tblOperator may work, but setting an id does NOT create a global variable of that name.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
var tbl = document.getElementById("tblOperator"); if (tbl) { tbl.style.display = "none"; } I believe that window.tblOperator may work, but setting an id does NOT create a global variable of that name.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
hi all i have a web page and a gridview inside it. In this gridview i added an item template, inside this item template i have a table called table main. Inside table main, in the last tr i have another table called tblOperator and an html button called btnview so the code looks like: <code> <asp:GridView ID="gvRaison" runat="server" AllowPaging="True" AutoGenerateColumns="False" PageSize="5" ShowHeader="False" Width="100%" DataKeyNames="RaisonId" EmptyDataText="No Data found"> <Columns> <asp:TemplateField HeaderText="Name"> <ItemTemplate> <table style="width: 100%;" Id="TableMain" class="TableMain"> <tr>. <tr> <input id="btnview" type="button" onclick="ShowHideTable(this);" value="Show" /> <table id="tblOperator" class="TableMain" style="width: 70%"> </code> i have wrote a javscript function to view/hide the tbloperator function ShowHideTable(args) { if (args.value=='Show') { tblOperator.style.display="block"; args.value= 'Hide'; } else if (args.value=='Hide') { tblOperator.style.display="none"; args.value= 'Show'; } } iam getting an error on this line tblOperator.style.display="none"; the error says tblOperator.style is null or not an object. how can i reference the tblOperator table and set its display?
-
Have you checked the source of the rendered page and confirmed the availability of the table? If you make the visibility as false by default, the control wont be rendered to the page. http://www.dustindiaz.com/seven-togglers/[^]
*jaans
-
I have already triewd this however it is giving me a design time error that tblOperator is not defined. ur right setting an id does not create a global variable of that name. Any other alternative. thanks
check what name we are geting in 'tbl'. and also check table,tr and td tags properly closed or not. I found that there are no td tags on your table.
smile :-)