Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

XML
var val = (abc/ efg)*100;
    document.getElementById("<%=txt1.ClientID%>").text = val;


but the value is not getting assigned

Please Help!
Posted
Comments
[no name] 5-Nov-12 6:27am    
if(document.getElementById("<%=txt1.ClientID%>"))
{
document.getElementById("<%=txt1.ClientID%>").value= (abc/ efg)*100;
}

Text box is html tag input of type text. It don't have text attribute.
It have value attribute. So:
JavaScript
var val = (abc/ efg)*100;
    document.getElementById("<%=txt1.ClientID%>").value= val;

That should working fine.

And hint: Use firebug (FF), developer tools (IE), OperaDragonfly etc. to check JS errors of you code. This will save you tons of time.
 
Share this answer
 
You're so very close. Change this:

JavaScript
var val = (abc/ efg)*100;
    document.getElementById("<%=txt1.ClientID%>").text = val;


to this:

JavaScript
var val = (abc/ efg)*100;
    document.getElementById("<%=txt1.ClientID%>").value = val;
 
Share this answer
 

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