ciao ragazzi.
sono nuovo, e sto improvvisando uno script personalizzato, copiando pezzi di script vari e cercando di adattarli e di legarli tra loro.
il problema è che non ho le basi e buttarmi senza nessuna nozione in questo mondo, percui diventa tutto assai complicato.. pure troppo.
ho cercato di risolvare passo dopo passo tutti i problemi che incontravo da solo, facendo prove e tentativi.. ora però non riesco a fare l'ultimo passo, ed ho bisogno di voi.
mi sono iscritto perce ho bisogno gentilmente del vostro aiuto per risolvere un poroblemino in un codice:
vorrei che i 2 select fossero dinamici. cioè vorrei che selezionando una "squadra"nel primo, non mi si ripresentasse lo stesso nome nel secondo select.
è possibile usando questo script modificare qualcosa per ottenere quello di cui ho bisogno?
(però vorrei che le altre funzioni rimanessero intatte)
grazie per l'aiuto. aspetto fiducioso.
leo
-----------------------------------------------------------------------------------------------------
<script language="javascript" src="db.js"></script>
<script language="javascript">
var tutti = "_and"
var alcuni = "_or"
var tipo_ricerca = ""
var s = 0
var o = 10
var copia_risultati = new Array()
var doc = parent.frames[1].document
function scriviform()
{
var testo1 = "";
var testo2 = "";
var Xsquadra = document.squadra.squ.selectedIndex;
var Xcontro = document.contro.con.selectedIndex;
switch(Xsquadra) {
case 1: testo1 = "milan"; break;
case 2: testo1 = "juve"; break;
case 3: testo1 = "inter"; break;
case 4: testo1 = "roma"; break;
case 5: testo1 = "napoli"; break;
}
switch(Xcontro) {
case 1: testo2 = "milan"; break;
case 2: testo2 = "juve"; break;
case 3: testo2 = "inter"; break;
case 4: testo2 = "roma"; break;
case 5: testo2 = "napoli"; break;
}
var tot = testo1 + " " + testo2;
document.cerca._query.value = tot;
}
function filtro (query) {
if (query.charAt(0) == "+")
{
query = query.substring (1, query.length)
tipo_ricerca = tutti
}
else
{
// Se vuoi che non ricerchi tutti i valori ma solo alcuni (quando manca il segno '+' correggi qui sotto, metti "alcuni"
tipo_ricerca = tutti
}
while (query.charAt(0) == " ") query = query.substring(1, query.length)
document.forms[0]._query.value = query
while (query.charAt(query.length - 1) == " ") query = query.substring(0, query.length - 1)
document.forms[0]._query.value = query
formatta_stringa (query)
}
function formatta_stringa (query) {
var stringa_formata = query.split (" ")
if (tipo_ricerca == "_or")
cerca_or (stringa_formata)
else
cerca_and (stringa_formata)
}
function cerca_or (stringa_formata) {
var matrix = new Array()
for (i = 0; i < db.length; i++)
{
var stringaConfronto = db.toUpperCase()
var stringaUtile = stringaConfronto.substring(0, stringaConfronto.lastIndexOf("|"))
for (j = 0; j < stringa_formata.length; j++)
{
var stringaUtente = stringa_formata[j].toUpperCase()
if (stringaUtile.indexOf(stringaUtente) != -1)
{
matrix[matrix.length] = db
break
}
}
}
verifica(matrix)
}
function cerca_and (stringa_formata) {
var matrix = new Array()
for (i = 0; i < db.length; i++)
{
var coincidenza = true
var stringaConfronto = db.toUpperCase()
var stringaUtile = stringaConfronto.substring(0, stringaConfronto.lastIndexOf("|"))
for (j = 0; j < stringa_formata.length; j++)
{
var stringaUtente = stringa_formata[j].toUpperCase()
if (stringaUtile.indexOf(stringaUtente) == -1)
coincidenza = false
}
if (coincidenza)
matrix[matrix.length] = db
}
verifica(matrix)
}
function verifica (matrix) {
if (matrix.length == 0)
{
doc.open()
doc.write('<html><head></head><body bgcolor="white"><hr size="1" noshade>')
doc.write('<font face="Verdana, Arial, sans" size="3"><div align="center">Spiacente, non ho trovato elementi corrispondenti</div></font><hr size="1" noshade></body></html>')
doc.close()
}
else
{
array_risultati = matrix.sort()
stampa_risultati(array_risultati, s, o)
}
}
function stampa_risultati(array_risultati, s, o) {
var limite = (array_risultati.length < s + o) ? array_risultati.length : (s + o)
doc.open()
doc.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body bgcolor="white">' + '<table width="90%" border="0">' + '<tr><td><hr size="1" noshade><tr><td> <font face="Verdana, Arial, sans" size="2" color="blue"><b>Chiave di ricerca: ' + '</font><i><font face="Verdana, Arial, sans" size="2" color="black">' + parent.frames[0].document.forms[0]._query.value + '</font></i><font face="Verdana, Arial, sans" size="2" color="blue">' + '<br>Risultati:' + '</font></i><font face="Verdana, Arial, sans" size="2" color="black">' + ' da ' + (s + 1) + ' a ' + limite + ' di ' + array_risultati.length + '</i></font>' + '</b><hr size="1" noshade>')
for (i = s; i < limite; i++)
{
var splitta = array_risultati.split("|")
doc.write('<tr><td align="right"><dl><font face="Verdana, Arial, sans" Color="red" size="2" >' + splitta[1] + '</font> </td><td><font face="Verdana, Arial, sans" Color="Black" size="2">' + splitta[2] + '</font> </td><td><font face="Verdana, Arial, sans" Color="Green" size="2">' + splitta[3] + '</font> </td><td><font face="Verdana, Arial, sans" Color="Green" size="2">' + splitta[4] + '</font> </td><td><font face="Verdana, Arial, sans" Color="Green" size="2">' + splitta[5] + '</i></font> </td></tr>')
}
doc.write('</table>')
visualizza_pulsanti (array_risultati, s, o)
doc.write('</body></html>')
doc.close()
}
function visualizza_pulsanti(array_risultati, s, o) {
doc.write('<form><div align="center">')
if (s + o < array_risultati.length)
{
doc.write('<input type="button" value="successivi" onClick="parent.frames[0].stampa_risultati(parent.frames[0].array_risultati, ' + (s + o) + ', ' + o + ')">')
}
if (s > 0)
{
doc.write('<input type="button" value="precedenti" onClick="parent.frames[0].stampa_risultati(parent.frames[0].array_risultati, ' + (s - o) + ', ' + o + ')">')
}
doc.write('</div></form>')
}
</script>
</head>
<body bgcolor="white">
<basefont face="Arial, Verdana, sans" size="2">
<table border="1" bgcolor="#FFC0CB" width="100%">
<form name ="cerca" onSubmit="filtro(document.forms[0].elements[0].value); return false">
<tr>
<td colspan="4" align="center">
<table width="100%">
<tr>
<td width="33%" align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">CERCA NEL DATABASE</font>
</td>
<td width="64%" align="center">
<input type="text" name="_query" size="50">
<br>
<input type=button value="Ricerca Partite" OnClick="filtro(document.forms[0].elements[0].value);">
<input type="reset" value="Azzera">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2"><a href="help.html" target="bot">Home</a></font>
</td>
</tr>
</table>
</td>
</tr>
</form>
</DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV>
<tr bgcolor="FFFFFF" >
<td width="50%">
<form name="squadra">
Squadra:<br>
<select name="squ" size="1" onchange="scriviform()">
<option>:: seleziona squadra ::</option>
<option>milan</option>
<option>juve</option>
<option>inter</option>
<option>roma</option>
<option>napoli</option>
</select>
</form>
</td>
<td width="50%">
<form name="contro">
Contro:<br>
<select name="con" size="1" onchange="scriviform()">
<option>:: seleziona avversario ::</option>
<option>milan</option>
<option>juve</option>
<option>inter</option>
<option>roma</option>
<option>napoli</option>
</select>
</form>
</td>
</form>
</td>
</tr>
</table>
</DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV>
</td>
</tr>
</table>
</div>
</body>
----------------------------------------------------------------------------------------------------------
sono nuovo, e sto improvvisando uno script personalizzato, copiando pezzi di script vari e cercando di adattarli e di legarli tra loro.
il problema è che non ho le basi e buttarmi senza nessuna nozione in questo mondo, percui diventa tutto assai complicato.. pure troppo.
ho cercato di risolvare passo dopo passo tutti i problemi che incontravo da solo, facendo prove e tentativi.. ora però non riesco a fare l'ultimo passo, ed ho bisogno di voi.
mi sono iscritto perce ho bisogno gentilmente del vostro aiuto per risolvere un poroblemino in un codice:
vorrei che i 2 select fossero dinamici. cioè vorrei che selezionando una "squadra"nel primo, non mi si ripresentasse lo stesso nome nel secondo select.
è possibile usando questo script modificare qualcosa per ottenere quello di cui ho bisogno?
(però vorrei che le altre funzioni rimanessero intatte)
grazie per l'aiuto. aspetto fiducioso.
leo
-----------------------------------------------------------------------------------------------------
<script language="javascript" src="db.js"></script>
<script language="javascript">
var tutti = "_and"
var alcuni = "_or"
var tipo_ricerca = ""
var s = 0
var o = 10
var copia_risultati = new Array()
var doc = parent.frames[1].document
function scriviform()
{
var testo1 = "";
var testo2 = "";
var Xsquadra = document.squadra.squ.selectedIndex;
var Xcontro = document.contro.con.selectedIndex;
switch(Xsquadra) {
case 1: testo1 = "milan"; break;
case 2: testo1 = "juve"; break;
case 3: testo1 = "inter"; break;
case 4: testo1 = "roma"; break;
case 5: testo1 = "napoli"; break;
}
switch(Xcontro) {
case 1: testo2 = "milan"; break;
case 2: testo2 = "juve"; break;
case 3: testo2 = "inter"; break;
case 4: testo2 = "roma"; break;
case 5: testo2 = "napoli"; break;
}
var tot = testo1 + " " + testo2;
document.cerca._query.value = tot;
}
function filtro (query) {
if (query.charAt(0) == "+")
{
query = query.substring (1, query.length)
tipo_ricerca = tutti
}
else
{
// Se vuoi che non ricerchi tutti i valori ma solo alcuni (quando manca il segno '+' correggi qui sotto, metti "alcuni"
tipo_ricerca = tutti
}
while (query.charAt(0) == " ") query = query.substring(1, query.length)
document.forms[0]._query.value = query
while (query.charAt(query.length - 1) == " ") query = query.substring(0, query.length - 1)
document.forms[0]._query.value = query
formatta_stringa (query)
}
function formatta_stringa (query) {
var stringa_formata = query.split (" ")
if (tipo_ricerca == "_or")
cerca_or (stringa_formata)
else
cerca_and (stringa_formata)
}
function cerca_or (stringa_formata) {
var matrix = new Array()
for (i = 0; i < db.length; i++)
{
var stringaConfronto = db.toUpperCase()
var stringaUtile = stringaConfronto.substring(0, stringaConfronto.lastIndexOf("|"))
for (j = 0; j < stringa_formata.length; j++)
{
var stringaUtente = stringa_formata[j].toUpperCase()
if (stringaUtile.indexOf(stringaUtente) != -1)
{
matrix[matrix.length] = db
break
}
}
}
verifica(matrix)
}
function cerca_and (stringa_formata) {
var matrix = new Array()
for (i = 0; i < db.length; i++)
{
var coincidenza = true
var stringaConfronto = db.toUpperCase()
var stringaUtile = stringaConfronto.substring(0, stringaConfronto.lastIndexOf("|"))
for (j = 0; j < stringa_formata.length; j++)
{
var stringaUtente = stringa_formata[j].toUpperCase()
if (stringaUtile.indexOf(stringaUtente) == -1)
coincidenza = false
}
if (coincidenza)
matrix[matrix.length] = db
}
verifica(matrix)
}
function verifica (matrix) {
if (matrix.length == 0)
{
doc.open()
doc.write('<html><head></head><body bgcolor="white"><hr size="1" noshade>')
doc.write('<font face="Verdana, Arial, sans" size="3"><div align="center">Spiacente, non ho trovato elementi corrispondenti</div></font><hr size="1" noshade></body></html>')
doc.close()
}
else
{
array_risultati = matrix.sort()
stampa_risultati(array_risultati, s, o)
}
}
function stampa_risultati(array_risultati, s, o) {
var limite = (array_risultati.length < s + o) ? array_risultati.length : (s + o)
doc.open()
doc.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body bgcolor="white">' + '<table width="90%" border="0">' + '<tr><td><hr size="1" noshade><tr><td> <font face="Verdana, Arial, sans" size="2" color="blue"><b>Chiave di ricerca: ' + '</font><i><font face="Verdana, Arial, sans" size="2" color="black">' + parent.frames[0].document.forms[0]._query.value + '</font></i><font face="Verdana, Arial, sans" size="2" color="blue">' + '<br>Risultati:' + '</font></i><font face="Verdana, Arial, sans" size="2" color="black">' + ' da ' + (s + 1) + ' a ' + limite + ' di ' + array_risultati.length + '</i></font>' + '</b><hr size="1" noshade>')
for (i = s; i < limite; i++)
{
var splitta = array_risultati.split("|")
doc.write('<tr><td align="right"><dl><font face="Verdana, Arial, sans" Color="red" size="2" >' + splitta[1] + '</font> </td><td><font face="Verdana, Arial, sans" Color="Black" size="2">' + splitta[2] + '</font> </td><td><font face="Verdana, Arial, sans" Color="Green" size="2">' + splitta[3] + '</font> </td><td><font face="Verdana, Arial, sans" Color="Green" size="2">' + splitta[4] + '</font> </td><td><font face="Verdana, Arial, sans" Color="Green" size="2">' + splitta[5] + '</i></font> </td></tr>')
}
doc.write('</table>')
visualizza_pulsanti (array_risultati, s, o)
doc.write('</body></html>')
doc.close()
}
function visualizza_pulsanti(array_risultati, s, o) {
doc.write('<form><div align="center">')
if (s + o < array_risultati.length)
{
doc.write('<input type="button" value="successivi" onClick="parent.frames[0].stampa_risultati(parent.frames[0].array_risultati, ' + (s + o) + ', ' + o + ')">')
}
if (s > 0)
{
doc.write('<input type="button" value="precedenti" onClick="parent.frames[0].stampa_risultati(parent.frames[0].array_risultati, ' + (s - o) + ', ' + o + ')">')
}
doc.write('</div></form>')
}
</script>
</head>
<body bgcolor="white">
<basefont face="Arial, Verdana, sans" size="2">
<table border="1" bgcolor="#FFC0CB" width="100%">
<form name ="cerca" onSubmit="filtro(document.forms[0].elements[0].value); return false">
<tr>
<td colspan="4" align="center">
<table width="100%">
<tr>
<td width="33%" align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">CERCA NEL DATABASE</font>
</td>
<td width="64%" align="center">
<input type="text" name="_query" size="50">
<br>
<input type=button value="Ricerca Partite" OnClick="filtro(document.forms[0].elements[0].value);">
<input type="reset" value="Azzera">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2"><a href="help.html" target="bot">Home</a></font>
</td>
</tr>
</table>
</td>
</tr>
</form>
</DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV>
<tr bgcolor="FFFFFF" >
<td width="50%">
<form name="squadra">
Squadra:<br>
<select name="squ" size="1" onchange="scriviform()">
<option>:: seleziona squadra ::</option>
<option>milan</option>
<option>juve</option>
<option>inter</option>
<option>roma</option>
<option>napoli</option>
</select>
</form>
</td>
<td width="50%">
<form name="contro">
Contro:<br>
<select name="con" size="1" onchange="scriviform()">
<option>:: seleziona avversario ::</option>
<option>milan</option>
<option>juve</option>
<option>inter</option>
<option>roma</option>
<option>napoli</option>
</select>
</form>
</td>
</form>
</td>
</tr>
</table>
</DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV>
</td>
</tr>
</table>
</div>
</body>
----------------------------------------------------------------------------------------------------------