Reputation: 1591
I have defined a hidden filed in aspx:-
<asp:HiddenField runat ="server" ID="hfBrand" value = "False" />
A combo-box control is calling a JavaScript function function:-
<telerik:RadComboBox ID="Brands" runat="server"
onclientselectedindexchanged="LoadProperties"
AutoPostBack="True">
</telerik:RadComboBox>
In that function , I am trying to set that hidden field value to "True":-
function LoadProperties(sender, eventArgs)
{
var lblBrand = document.getElementById('<%= hfBrand.ClientID %>').value;
alert(lblBrand);
document.getElementById('<%= hfBrand.ClientID %>').value = "True";
alert(lblBrand)
}
QUESTION:- I can't set the hidden field value to TRUE. WHY it so?? and How to do that?
UPDATE:- Here is the solution which got me right desired output:-
var lblBrand = document.getElementById('<%= hfBrand.ClientID %>').value;
alert(lblBrand);
lblBrand = "True";
alert (lblBrand);
Thnx to everyone who helped me.
Upvotes: 0
Views: 17277
Reputation: 3080
Your second alert is not referring to the hidden values new value. lblBrand value doesnt change after you have updated the hfBrand input value
function LoadProperties(sender, eventArgs)
{
var lblBrand = document.getElementById('<%= hfBrand.ClientID %>');
alert(lblBrand.value);
document.getElementById('<%= hfBrand.ClientID %>').value = "True";
alert(lblBrand.value)
}
Try this code!
I reckon it is setting it and you need to get the value of the input again...
(if you wanna see the change, just temporarily change your hidden input to a normal textbox
Upvotes: 5