Click here to Skip to main content
16,016,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a problem. I call a java script in onChange event of dropdownlist.In that java script i have set a value to a hidden field but when the page is post backthe value of hidden field becomes null(DropdownList has a SelectedindexChanged Event and its AutopostBack Property is True.This Property Must be true.).I want to check the value of Hidden Field on Server side code of dropdownlist which was set by java script.Any one can help me.
My javascript Code is-
JavaScript
function ChaekDdl(id)
    {
   
    var ddl=document.getElementById(id);
    var hiddenField = document.getElementById('HiddenField1');
    if(ddl.options[ddl.selectedIndex].value=="1")
     {   //var check=confirm('Are You Sure?');    
            if(confirm('Are You Sure?'))
             {   
                //document.getElementById('TextBox1').value='1';       
                hiddenField.value = '1';
                return true;
            }
            else
            {
                hiddenField.value = '0';
                return false;
            }

    }
  }


Thanks in advance.
Posted
Updated 2-Aug-11 19:52pm
v2

1 solution

Do Changes like below
JavaScript
var hiddenField = document.getElementById('<% = HiddenField1.ClientID %>');
 
Share this answer
 
v2
Comments
koolprasad2003 3-Aug-11 2:12am    
Nice Ans. My 4, Raja I think he has given single Quot in document.getElementById("HiddenField1").
MDubey1987 3-Aug-11 3:40am    
Thanks for Your Ans.Its working fine on IE but not in Firefox

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900