Reputation: 5
I have an object that i want to hide. it is a row from a datagrid on my website. The data from the grid is dynamic. I want this row to hide/not be visible when i click on my selection of "computer" in my dropdownlist. i think i have to use getElementById().
This is the id that i want to hide
<span id="dg_form_ctl05_lbl_show_tag" style="display:inline-block;background-color:Transparent;border-color:Navy;border-width:3px;border-style:Double;font-family:Arial;font-size:12px;width:130px;">Subject*</span>
this is the dropdownlist id. dg_form_ctl02_DropDownList1
This is the code that i have so far but it doesn't seem correct because it's not hiding the row when i run it.
function hideMe() {
var g = document.getElementById("dg_form_ctl05_lbl_show_tag");
var e = document.getElementById("dg_form_ctl02_DropDownList1");
if(e == "Computer")
g.style.display = 'none';
}
I think i need to use code-behind on this also here is the code i have so far for c#.
if (!ClientScript.IsStartupScriptRegistered("hwa"))
{
ClientScript.RegisterStartupScript(this.GetType(), "hwa", "hideMe();", true);
}
can someone help me?
Upvotes: 0
Views: 133
Reputation: 14419
function hideMe() {
var g = document.getElementById("dg_form_ctl05_lbl_show_tag");
var e = document.getElementById("dg_form_ctl02_DropDownList1").value;
if(e == "Computer")
g.style.display = 'none';
}
Upvotes: 0
Reputation: 144689
You should use the value
property for getting the value of the select element, currently you are comparing a string
with an object
, try this:
var e = document.getElementById("dg_form_ctl02_DropDownList1").value;
Upvotes: 1