Problem comparing string variable: if statement not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sabel
    New Member
    • May 2009
    • 3

    #1

    Problem comparing string variable: if statement not working

    Hi
    I am a problem comparing DDC AND "DDC" , the if statement is not working.
    here is my javascript code

    Code:
    var DDC=document.getElementById("<%= hvalue.ClientID %>").value; 
               
             if  (DDC=="DDC")
                 {
                  radalert (DDC); 
                 }
    Thanks
    Last edited by Dormilich; May 8 '09, 05:46 AM. Reason: added [code] tags
  • DaiOz
    New Member
    • May 2009
    • 16

    #2
    Can u start your own thread please mate

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Quite right. I've split this off into its own thread. Please do not hijack other members' threads.

      Onto your problem: do you get any errors? Have you checked that the value is really "DDC"?

      Comment

      • sabel
        New Member
        • May 2009
        • 3

        #4
        Yes, this how a go about it.
        var DDC=document.ge tElementById("< %= hvalue.ClientID %>").value;
        alert(ddc);
        and the popup display DDC
        pls help.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Check that there's no spaces. If there's a space it won't show on the alert, but an exact comparison would fail.

          Comment

          • sabel
            New Member
            • May 2009
            • 3

            #6
            Thanks
            now working.

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              That was easy, wasn't it? :)

              Comment

              Working...