By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Probs on ParseInt(maybe)

P: 83
Expand|Select|Wrap|Line Numbers
  1. if (NICNo.length==12 && (!isNAN(NICNo)))
  2. {
  3. OICNo="masukdah";
  4.     if (parseInt(NICNo.charAt(11)) % 2 == 0)
  5.     {
  6.         //document.getElementById("rad1Lelaki").checked=false;
  7.         document.getElementById("rad1Perempuan").checked=true;
  8.     }else{
  9.         document.getElementById("rad1Perempuan").checked=false;
  10.         document.getElementById("rad1Lelaki").checked=true;
  11.  
  12.     }
  13. }else
  14. {
  15. document.getElementById("ErrorList1").style.display="block";
  16. Allvalid=false;
  17. }
i GET ERROR at second if with the operation parseInt and modulus and also compare to 0
Oct 9 '08 #1
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
What's the error message?
Oct 9 '08 #2

P: 83
Again sorry guys got debug the probs...
it was function isNaN ....pewh javascript sure strict
(isNaN(NICNo))
but got another probs...
Expand|Select|Wrap|Line Numbers
  1. 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
Oct 9 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Yes, JavaScript is case-sensitive.
Oct 9 '08 #4

rnd me
Expert 100+
P: 427
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
Oct 9 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.