Click here to Skip to main content
16,008,490 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi to All,

I want to Compare the Two Textbox ClientId, not a Value of them, whether clientid is equals to i, perform something oterwise not.


C#
for (var i = 2; i <= document.getElementById('ctl00_cphMaster_grdPaymentAmount').rows.length - 1; i++)
{
     if(document.getElementById('ctl00_chMaster_ctl04_txtPayAmount') == document.getElementById('ctl00_chMaster_ctl0' + i +'_txtPayAmount'))
     alert("Some");
}


because I bind the textbox into gridview, so the value of the textbox is entirely different to previous value.

but the if statement match all loop increment.

How can i do this?

Please Help me.

Thanks a lot.
Posted
Updated 7-Jul-10 4:48am
v3
Comments
Sandeep Mewara 7-Jul-10 12:22pm    
Better would be to explain your scenario. Looks like there can be a simpler solution then what you are planning to implement.
Further, if there is any gridview and textbox into it which is being accessed, clearly mention those stuff in your question such that one can suggest you correct way.

1 solution

Are you trying to test to see if a control exists so you can perform an action if it does? If so try something like this...

XML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <title>test</title>
    </head>
    <body>

    <span id="ctl00_chMaster_ctl04_txtPayAmount">my control text</span>

    <script type="text/javascript">

        // the fourth loop should return true all others should return false
        for(var i =1;i <= 5;i++){
            if(document.getElementById("ctl00_chMaster_ctl0" + i + "_txtPayAmount") != null){
                window.alert(true);
            }
            else {
                window.alert(false)
            }
        }

    </script>
    </body>
</html>
 
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