Posted By

abwaters on 03/19/09


Tagged

ISBN UPC


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

jamesming


Convert UPC to ISBN


 / Published in: JavaScript
 

URL: http://www.eblong.com/zarf/bookscan/index.html#convert

  1. if (indexisbn.indexOf("978") == 0) {
  2. isbn = isbn.substr(3,9);
  3. var xsum = 0;
  4. var add = 0;
  5. var i = 0;
  6. for (i = 0; i < 9; i++) {
  7. add = isbn.substr(i,1);
  8. xsum += (10 - i) * add;
  9. }
  10. xsum %= 11;
  11. xsum = 11 - xsum;
  12. if (xsum == 10) { xsum = "X"; }
  13. if (xsum == 11) { xsum = "0"; }
  14. isbn += xsum;
  15. }

Report this snippet  

You need to login to post a comment.