Salve come faccio ad impostare una variabile all'onclick?
Il mio codice è questo:
All'inizio si trovano dei pulsanti, io devo fare in modo che al click la variabile ord assuma un valore che è o 1 oppure -1...codice:function disegna(box,path,ordc) { st ="<table border=1 id=\"table\">"; st+="<tr><td><button value=\"cre\" id=\"crescente\" onclick=\"icrescente(); tab.disegna('"+box+"','"+path+"','"+1+"'); \"></button></td><td><button value=\"dec\" id=\"decrescente\" onclick=\"idecrescente(); tab.disegna('"+box+"','"+path+"','"+ord+"'); \"></button></td>"+ "<td><button value=\"cre\" id=\"crescente\" onclick=\"icrescente(); tab.disegna('"+box+"','"+path+"','"+1+"'); \"></button></td><td><button value=\"dec\" id=\"decrescente\" onclick=\"idecrescente(); tab.disegna('"+box+"','"+path+"','"+ord+"'); \"></button></td>"+ "<td><button value=\"cre\" id=\"crescente\" onclick=\"icrescente(); tab.disegna('"+box+"','"+path+"','"+1+"'); \"></button></td><td><button value=\"dec\" id=\"decrescente\" onclick=\"idecrescente(); tab.disegna('"+box+"','"+path+"','"+ord+"'); \"></button></td>"+ "<td><button value=\"cre\" id=\"crescente\" onclick=\"icrescente(); tab.disegna('"+box+"','"+path+"','"+1+"'); \"></button></td><td><button value=\"dec\" id=\"decrescente\" onclick=\"idecrescente(); tab.disegna('"+box+"','"+path+"','"+ord+"'); \"></button></td></tr>"; function icrescente() { ordc = 1; return ordc; } function idecrescente() { ordc = -1; return ordc; } function normal() { ordc = 0; return ordc; } var ord=ordc; for (var y in this.array) st+="<tr id=\""+y+"\"></tr>"; st+="</table>"; document.getElementById(box).innerHTML=st; for (var y in this.array) this.posiziona(y,ordc); }

Rispondi quotando
