Scusate ma a questo punto volevo mettere in pratica il suggerimento solo che non so bene come procedere.
Allora io ho un campo testo dove ho ho il codice che mi viene estratto dal database.
Dal database posso estrarre tranquillamente anche la quantità caricata.
Ora il mio problema è questo.
Dal vostro suggerimento dovrei creare tante etichette quanti sono i pezzi entrati.
Per generare il codice a barre utilizzo questo script che trovato qui da voi:
Codice a barre
Come posso adattare lo script per fare in modo che mi venga creato il numero di etichette da me inserito in precedenza nel DB.
Dovrei passare allo script il la quantità inserita ma non so sinceramente dove inserirla, oppure si può procedere in altro modo.
Potete fornirmi dei suggerimenti?
Vi posto il javascript:
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 - Magazzino</title>");
doc.writeln("<link rel=stylesheet type=text/css href=print.css media=print> ");
doc.write("</head><body><div align=center>");
// 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("<div id=bottoneStampa><input type=button value=Stampa onClick=window.print()></div></div></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;
}
e questo è il codice del form:
codice:
<form name=myForm>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="159" align="left" class="titolini">Descrizione</td>
<td width="338" align="left" class="titolini">Campo</td>
</tr>
<tr>
<td colspan="2">[img]immagini/null.gif[/img]</td>
</tr>
<tr>
<td width="159" align="left" class="testoDati">Codice prodotto completo:</td>
<td align="left" class="testoDati"> <input name="codice" type="text" class="testoDati" onkeyup="CheckL(this)" value="<%=(rsDettagli.Fields.Item("codTipoArticolo").Value)%><%=(rsDettagli.Fields.Item("codFornitore").Value)%><%=(rsDettagli.Fields.Item("codMarca").Value)%><%=(rsDettagli.Fields.Item("codTaglia").Value)%><%=(rsDettagli.Fields.Item("codColore").Value)%>" size="20" maxlength="13" />
<input type="hidden" size="1" name="larghezza" value="1" onkeyup="CheckL(this)" />
<input type="hidden" size="3" name="altezza" value="0" onkeyup="CheckL(this)" />
<input name="calcola" type="checkbox" class="footer" />
<label>
<input name="pezziTotali" type="text" class="testoDati" id="pezziTotali" value="<%=(rsDettagli.Fields.Item("confPerScatola").Value)%>" size="10" />
</label></td>
</tr>
<tr>
<td colspan="2" class="footer">[img]immagini/null.gif[/img]</td>
</tr>
<tr>
<td colspan="2" align="center" class="footer">[img]immagini/null.gif[/img]</td>
</tr>
<tr>
<td colspan="2" align="center"><label>
<input type=button class="testo" onclick="PopBar();" value="Genera etichetta">
</label></td>
</tr>
</table>
</form>
Grazie a tutti in anticipo e ciao.