Probs on ParseInt(maybe)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MATTXtwo
    New Member
    • Sep 2006
    • 83

    Probs on ParseInt(maybe)

    Code:
    if (NICNo.length==12 && (!isNAN(NICNo)))
    {
    OICNo="masukdah";
    	if (parseInt(NICNo.charAt(11)) % 2 == 0)
    	{
    		//document.getElementById("rad1Lelaki").checked=false;
    		document.getElementById("rad1Perempuan").checked=true;
    	}else{
    		document.getElementById("rad1Perempuan").checked=false;
    		document.getElementById("rad1Lelaki").checked=true;
    		
    	}
    }else
    {
    document.getElementById("ErrorList1").style.display="block";
    Allvalid=false;
    }
    i GET ERROR at second if with the operation parseInt and modulus and also compare to 0
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    What's the error message?

    Comment

    • MATTXtwo
      New Member
      • Sep 2006
      • 83

      #3
      Again sorry guys got debug the probs...
      it was function isNaN ....pewh javascript sure strict
      (isNaN(NICNo))
      but got another probs...
      Code:
      var Negeri=document.getElementById("State").options[document.getElementById("State").selectedIndex].text;
      I want to know how to retrieve <select> selected value and to set the selected value to some value

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Yes, JavaScript is case-sensitive.

        Comment

        • rnd me
          Recognized Expert Contributor
          • Jun 2007
          • 427

          #5
          parseInt doesn't like numbers that start with 0.

          you should always specifiy a radix when using parseInt.

          this is usually 10.

          so instead of alert( parseInt( "0010" ) ); // shows: 8

          try:

          alert( parseInt( "0010" , 10) ); // shows: 10

          Comment

          Working...