Ho trovato su internet questo codice:

codice:
// (c) br1 - 2002 ------------------------- mailto:br1@freemail.it
// ---------------------------------------------------------------
function CheckL(obj) {
// -------------------------------------- controllo input numerici
	chrOk = "0123456789"
	o = obj.value;
	a = o.charAt(o.length-1);
	if (chrOk.indexOf(a)==-1) 
		obj.value=o.substr(0,o.length-1);
}

// ---------------------------------------------------------------
function PopBar() {
// ------------------------ creazione e scrittua PopUp con BarCode
// parametri e controlli
codice = document.myForm.codice.value;
largo = parseFloat("0" + document.myForm.larghezza.value)
// larghezza della barra
if (largo<1) 
	largo=1;
if (largo>9) 
	largo=9;

alto = parseFloat("0" + document.myForm.altezza.value);
if (alto<1) 
	alto=(largo*45); // automatico
if (alto>screen.availHeight) 
	alto=screen.availHeight-(110+largo*12); // limito in base allo schermo
calcola = document.myForm.calcola.checked;

// Codice da visualizzare: aggiusto la lunghezza a 13 cifre
	while(codice.length<13)	{codice="0"+codice};

// se c'e' da calcolare e sostituire il Check Digit
if (calcola) {
	LL = codice.length;
	if (LL > 12) { 
		LL = 12
		codice = codice.substr(0,12)
	}
	tt = 0
	for (xx=1;xx<=LL;xx++) {
	  vv = parseInt(codice.substr(LL-xx,1))
	  if (xx%2 == 1) 
		  vv=vv*3;
	  tt = tt + vv
	}
	tt = tt % 10
	if (tt > 0) 
		tt = 10 - tt;
//	' accodo il Check Digit al numero
	codice = codice + tt
}

// chiudo la pop-up (se esiste)
if (typeof(pop)=="object") if (typeof(pop.name)!="unknown") pop.close();

// apro e scrivo la pop-up
pop=window.open("","barc","top=0,left=0,width="+(largo*105+60)+",height="+(alto+largo*12+80));
doc=pop.document;
doc.writeln("<html><head><title>BarCode &copy; br1 - 2002</title>");
doc.write("</head><body>");
// cornice
doc.write("<table width=1 height=1 cellpadding=10 cellspacing=0 bgcolor=silver align=center><tr><td>");
doc.write("<table width=1 height=1 cellpadding=10 cellspacing=0 bgcolor=white><tr><td>");
// BarCode
doc.write(TabBar(largo,alto,BinBar(codice),codice));
// fine cornice
doc.write("</td></tr></table>");
doc.write("</td></tr></table>");
doc.write("</body></html>");
doc.close();
pop.focus();
}

// ---------------------------------------------------------------
function TabBar(largo,alto,binario,codice) {
// ------------------------- creazione stringa con tabella BarCode
prima = codice.substr(0,1);
seconda = codice.substr(1,6);
terza = codice.substr(7);

tabella = "";
tabella += "<table bgcolor=white border=0 cellpadding=0 cellspacing=0>"; 
tabella += "<tr><td></td><td valign=top rowspan=2>";
ii=0
for (kk=1;kk<96;kk++) { 
	ii = 1-ii
	aa = alto;
	if (kk<4||kk>92||kk==46||kk==47||kk==48||kk==49||kk==50) 
		aa=largo*4+alto;		// barre di controllo e sincronizzazione
	tabella += "[img]+binario.charAt(kk-1)+[/img]";
	if (kk==3||kk==50) 
		tabella += "</td><td valign=top>";
	if (kk==45||kk==92) 
		tabella += "</td><td valign=top rowspan=2>";
}
tabella += "</td></tr>";
// riga testi
tabella += "<tr>";
tabella += "<td align=center valign=bottom><input type=text style=\"text-align:center;width:";
tabella += 7*largo+";border:0;font-size:"+11*largo+"px;\" value=\""+prima+"\"></td>";
tabella += "<td align=center valign=bottom><input type=text style=\"text-align:center;width:";
tabella += 42*largo+";border:0;font-size:"+11*largo+"px;\" value=\""+seconda+"\"></td>";
tabella += "<td align=center valign=bottom><input type=text style=\"text-align:center;width:";
tabella += 42*largo+";border:0;font-size:"+11*largo+"px;;\" value=\""+terza+"\"></td>";
tabella += "</tr></table>";
return tabella
}

// ---------------------------------------------------------------
function BinBar(codice) {
// ------------------ creazione stringa binaria (0=bianco, 1=nero)
// tabella estrapolata da: www.barcodeisland.com/ean13.phtml
var a = new Array("000000000110101001111110010" ,
	"001011001100101100111100110",
	"001101001001100110111101100", 
	"001110011110101000011000010", 
	"010011010001100111011011100", 
	"011001011000101110011001110", 
	"011100010111100001011010000",
	"010101011101100100011000100",
	"010110011011100010011001000", 
	"011010000101100101111110100"); 

// identifico la sequenza della prima parte del codice (dipende dalla prima cifra)
seq = a[codice.substr(0,1)].substr(0,6); 

// creo la sequenza del barcode 
cc = "101";
dd = codice.substr(1,6);
for (kk=0;kk<6;kk++) {
	aa = dd.charAt(kk)
	bb = seq.charAt(kk)
	cc += a[aa].substr(bb*7+6,7)
}
cc += "01010"
dd = codice.substr(7);
for (kk=0;kk<6;kk++) {
	aa = dd.charAt(kk)
	cc += a[aa].substr(20,7)
}
cc += "101"

return cc;
}
ma stampa solo numeri da 13 è possibile modificare il codice in modo da stampare solo 10 numeri???

Grazie per il vostro aiuto.