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

I am using the javascript in my application. I want to change the value of the label as yes or no based on the value entered in the text box and checking the condition in the label. Here is the script I am using in my application:

XML
<script language="javascript" type="text/javascript" >
     function TextChange() {
         var ProjectValue = document.getElementById('<%=txtApproxBidVal.ClientID%>').value;
         var Param = document.getElementById("<%= lblCondition.ClientID %>").innerHTML;
         if (parseInt(ProjectValue.value) > Param.innerHTML)
         {
             var yesnotext = document.getElementById("<%= lblYesNo.ClientID %>").innerHTML;
              yesnotext.value ="Yes";
          }
          else if (parseInt(ProjectValue.value) < Param.innerHTML)
          {
              var yesnotext = document.getElementById("<%= lblYesNo.ClientID %>").innerHTML;
              yesnotext.value = "No";
          }
     }
     </script>


Is there any changes in this code. Can any one help me to solve this problem.

Thanks in Advance

[edit]Tags only (C# was not correct) - OriginalGriff[/edit]
Posted
Updated 27-Nov-11 21:34pm
v2
Comments
D K N T H 28-Nov-11 3:36am    
is it free from errors?
[no name] 28-Nov-11 4:07am    
see error using IE

Why didn't you parse the right side values?
JavaScript
if (parseInt(ProjectValue.value) > parseInt(Param.innerHTML)) { }
 
Share this answer
 
Comments
Member 7946563 28-Nov-11 3:48am    
I tried in that way also but its not going inside the condition if the condition is true or false
thatraja 28-Nov-11 3:52am    
Check the value of ProjectValue.value & Param.innerHTML. Validate if those values are non-numeric. Use isNaN for that
JavaScript
function TextChange() 
{
        if (eval(document.getElementById("txtApproxBidVal").value) > eval(document.getElementById("lblYesNo").innerHTML))
        {
             document.getElementById("lblYesNo").innerHTML="Yes";
         }
         else
         {
             document.getElementById("lblYesNo").innerHTML = "No";
         }
    }
 
Share this answer
 
XML
<script language="javascript" type="text/javascript" >
     function TextChange() {
         var ProjectValue = document.getElementById('<%=txtApproxBidVal.ClientID%>');
         var Param = document.getElementById("<%= lblCondition.ClientID %>");
 var yesnotext = document.getElementById("<%= lblYesNo.ClientID %>");

         if (parseInt(ProjectValue.value) > parseInt(Param.innerText))
         {
                          yesnotext.innerHTML="Yes";
          }
          else if (parseInt(ProjectValue.value) < parseInt(Param.innerText))
          {
                            yesnotext.innerHTML= "No";
          }
     }
     </script>


Hope this helps.
 
Share this answer
 
v2

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