Abbiamo questo codice
<html><head><script LANGUAGE="JavaScript" type="text/javascript">
<!-- Start script
function createArray(length)
{
this.length = length;
for( var i = 1; i<= length; i++)
this* = null;
return this;
}
var Entries = 3;
var Separator = ";"
var Fields = 7;
var inome = 1;
var icognome = 2;
var ivia = 3;
var icitta = 4;
var itel = 5;
var imail = 6;
var ifoto = 7;
// ora creiamo un Array
var Data = new createArray(Entries);
Data[1] = "Giuseppe;rossi;via Piave;torino;01-1111;[email protected];";
Data[2] = "Aldo;bianchi;via Torino;milano;02-222;[email protected];";
Data[3] = "carlo;verdi;via milano;Roma;03-3333;[email protected];";
var LastMatch = 0;
function GetField(Entry,number)
{
var Out = "";
var FirstChar;
var LastChar;
FirstChar = 0;
LastChar = Entry.indexOf(Separator) ;
if (number == 1)
{
Out += Entry.substring(FirstChar,LastChar);
return Out;
}
if (number == Fields)
{
Out+= Entry.substring(Entry.lastIndexOf(Separator) + 1,Entry.length)
return Out;
}
for(var i =2; i <= number; i++)
{
FirstChar = LastChar + 1;
LastChar = Entry.indexOf(Separator, FirstChar);
}
Out += Entry.substring(FirstChar,LastChar);
return Out;
}
function FindNext(String, number)
{
var CompareWith = "";
for(var i = LastMatch + 1; i <=Data.length; i++)
{
var buf = GetField(Data*,number);
var bl = parseInt(buf.length);
var sl = parseInt(String.length);
if(bl > sl)
{
CompareWith = buf.substring(0,sl );
}
else
{
CompareWith = buf;
}
if (CompareWith == String)
{
LastMatch = i;
return i;
}
}
LastMatch = 0;
return 0;
}
function ResetSearch()
{
LastMatch = 0;
for(var i = 1; i <=Fields; i++)
{
document.SearchForm.elements[i+3].value = "";
}
}
function TypeNext()
{
var SearchString = document.SearchForm.Text.value;
var index =document.SearchForm.elements[3].options.selectedIndex + 1;
var j = FindNext(SearchString, index);
if (j == 0)
{
alert("Fine");
ResetSearch();
return;
}
var buf = "";
for(var i = 1; i <=Fields; i++)
{
buf = GetField(Data[j],i);
document.SearchForm.elements[i+3].value = buf;
}
}
// end script -->
</script>
<bfy>
<FORM NAME="SearchForm" onSubmit = "TypeNext();return false">
<INPUT NAME="Text" TYPE="TEXT" ROWS=1 COLS=20>
<INPUT NAME="FindNext" TYPE="SUBMIT" VALUE="Cerca >>>">
<INPUT NAME="NewSearch" TYPE="Reset" VALUE="Nuova ricerca" onClick ="ResetSearch();">
Ricerca per: <SELECT VALUE="field" SIZE=1>
<OPTION>nome
<OPTION>cognome
</SELECT>
**
nome<INPUT NAME="Result1" FONT COLOR="#FF0000" TYPE="TEXT" ROWS=1 COLS=30 SIZE="25">
cognome<INPUT NAME="Result2" TYPE="TEXT" ROWS=1 COLS=15 SIZE="25">
abitazione<INPUT NAME="Result3" TYPE="TEXT" ROWS=1 COLS=31 SIZE="25">
citta<INPUT NAME="Result4" TYPE="TEXT" ROWS=1 COLS=20 SIZE="25">
tel<INPUT NAME="Result5" TYPE="TEXT" ROWS=1 COLS=25 SIZE="25">
mail<INPUT NAME="Result6" TYPE="TEXT" ROWS=1 COLS=31 SIZE="10">
<INPUT NAME="Result7" TYPE="TEXT" ROWS=1 COLS=30 SIZE="35">
</FORM>
</head></body></html>
nel result7 vogliamo inserire un ink a una immagine che mettiamo in
nei vari data.
problema: non mi riconosce il <img src=.....>
come si fa? Grazie