Convert UPC to ISBN


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.