Hi!
I have made a pretty cool .asp/javascript I would like to share with you guys! The script is an. asp scripts that read a semicolon separeted text file with phonenumbers and adresses.I file like this can you make in excel or something. After .asp file have read the text file, it creates a html file. And create a link to it. With this html you can search for phone numbers by an javascript. The javascript then make another html page with the result! And even on this new page it create javascripts. When you click on the personsname you got an alert-box with the adress, phonenuer etc.. Pretty cool?..
The reason why i not just use an .asp page to do the search also is that would like to have a search engine for phonenumbers on my pocket pc even if I am offline..
Her is the code. Please look at it and give me some coments! Thanks
<%@LANGUAGE="VBScript"%>
<HTML>
<HEAD>
<TITLE>Make phonelist</TITLE>
<!-- METADATA TYPE="typelib" FILE="c:\WinNT\System32\scrrun.dll" -->
</HEAD>
<BODY>
<%
strTextFile = "d:dir\nam.txt"
strHtmlFile = "d:dir\phonelist.htm"
text="<html><head></head>"&VBcrlf
text=text+"<script language='JavaScript'>nam='"
'create an instance of a FileSytemObject object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
'open the text file as a TextStream object
Set objTStream = objFSO.OpenTextFile(strTextFile, ForReading)
'read one line at a time until the end of the file is reached
Do While Not objTStream.AtEndOfStream
text=text+"_"+objTStream.ReadLine
Loop
objTStream.Close
text=text+"'"&VBcrlf
text=text+"function search(){"&VBcrlf
text=text+"var html="&Chr(34)&"<html><head><TITLE>Phone search results</TITLE></head><body>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"<table border=0 cellpadding=2 cellspacing=0><tr><td colspan=2>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"<font face=helvetica>If dialing from the outside use 5169 prefix for Risavika, so that 14-9999 becomes 51 69 99 99. </font>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"</td></tr>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"<tr><td bgcolor='#003366'><font color=beige face='helvetica,arial'><b>Surname</td><td bgcolor='#003366'><font color=beige face='helvetica,arial'><b>First name</td></tr>"&Chr(34)&";"&VBcrlf
text=text+"var re,line,r,s,i=0,n,name; "&VBcrlf
text=text+"if (document.form1.ka[0].checked) {n=0;name='Firstname: ';}"&VBcrlf
text=text+"else {n=1;name='Surname: ';}"&VBcrlf
text=text+"re = form1.searchstring.value;"&VBcrlf
text=text+"re=re.toUpperCase();"&VBcrlf
text=text+"nam=nam.toUpperCase();"&VBcrlf
text=text+"line=nam.split('_');"&VBcrlf
text=text+"for(var j=0;j<line.length;j++){"&VBcrlf
text=text+"s=line[j].split(';');"&VBcrlf
text=text+"if(s[n].indexOf(re)!='-1'){"&VBcrlf
text=text+"i=i+1;"&VBcrlf
'text=text+"html=html+"&Chr(34)&"<tr><td><font face=verdana size=1><a href='javascript: void null()' onclick=\"&Chr(34)&"alert('Name: "&Chr(34)&"+s[0]+"&Chr(34)&" "&Chr(34)&"+s[1]+"&Chr(34)&"\\nDepartment: "&Chr(34)&"+s[2]+"&Chr(34)&"\\nOffice-no.: "&Chr(34)&"+s[3]+"&Chr(34)&"\\nInt.phone: "&Chr(34)&"+s[4]+"&Chr(34)&"\\nPrivate: "&Chr(34)&"+s[5]+"&Chr(34)&"\\nMobile: "&Chr(34)&"+s[7]+"&Chr(34)&"\\nPager: "&Chr(34)&"+s[8]+"&Chr(34)&"\\nAddress: "&Chr(34)&"+s[6]+"&Chr(34)&"')\"&Chr(34)&">"&Chr(34)&"+s[1]+"&Chr(34)&"</a></font></td><td>"&Chr(34)&"+s[0]+"&Chr(34)&"</td></tr>"&Chr(34)&";" &VBcrlf
text=text+"html=html+"&Chr(34)&"<tr><td><font face=verdana size=1><a href='javascript: void null()' onclick=\"&Chr(34)&"confirm('Name: "&Chr(34)&"+s[0]+"&Chr(34)&" "&Chr(34)&"+s[1]+"&Chr(34)&"\\nDepartment: "&Chr(34)&"+s[2]+"&Chr(34)&"\\nOffice-no.: "&Chr(34)&"+s[3]+"&Chr(34)&"\\nInt.phone: "&Chr(34)&"+s[4]+"&Chr(34)&"\\nPrivate: "&Chr(34)&"+s[5]+"&Chr(34)&"\\nMobile: "&Chr(34)&"+s[7]+"&Chr(34)&"\\nPager: "&Chr(34)&"+s[8]+"&Chr(34)&"\\nAddress: "&Chr(34)&"+s[6]+"&Chr(34)&"')\"&Chr(34)&">"&Chr(34)&"+s[1]+"&Chr(34)&"</a></font></td><td>"&Chr(34)&"+s[0]+"&Chr(34)&"</td></tr>"&Chr(34)&";" &VBcrlf
text=text+"}}"&VBcrlf
text=text+"html=html+"&Chr(34)&"</table><p><font face='verdana' size=1><b>"&Chr(34)&"+i+"&Chr(34)&" hits for "&Chr(34)&"+name+form1.searchstring.value+"&Chr(34)&"</b></font></p>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"<p><font face='verdana' size=1>[<a href='phonelist.htm'>Search again</a>]</font></p>"&Chr(34)&VBcrlf
text=text+"html=html+"&Chr(34)&"</html>"&Chr(34)&";"&VBcrlf
text=text+"document.write(html);"&VBcrlf
text=text+"nnn=nnn.value;"&VBcrlf
text=text+"}"&VBcrlf
text=text+"</script>"&VBcrlf
text=text+"<body>"&VBcrlf
text=text+"<h1>Phonebook for SEPNo</h1>"&VBcrlf
text=text+"<font face=helvetica>Search for</font><br>"&VBcrlf
text=text+"<form name='form1' onsubmit='search()'>"&VBcrlf
text=text+"<font face=helvetica>Firstname <input type='radio' name='ka' value='1' checked> Surname<input type='radio' name='ka' value='0'></font><br>"&VBcrlf
text=text+"<input type='text' name='searchstring'>"&VBcrlf
text=text+"<input type='button' value='Search' onclick='search()'>"&VBcrlf
text=text+"</form>"&VBcrlf
text=text+"</body>"&VBcrlf
text=text+"</html>"&VBcrlf
'Response.Write text
'Writes to the file phonelist.htm
Set objTStream = objFSO.OpenTextFile(strHtmlFile, ForWriting, True)
arrLines = Split(text, vbCrLf)
For intLine = 0 To UBound(arrLines)
objTStream.WriteLine arrLines(intLine)
Next
objTStream.Close
%>
<a href="phonelist.htm"> the list </a>
</BODY>
</HTML>
Jørn Arild Andenæs
jaa@jaa.no
I have made a pretty cool .asp/javascript I would like to share with you guys! The script is an. asp scripts that read a semicolon separeted text file with phonenumbers and adresses.I file like this can you make in excel or something. After .asp file have read the text file, it creates a html file. And create a link to it. With this html you can search for phone numbers by an javascript. The javascript then make another html page with the result! And even on this new page it create javascripts. When you click on the personsname you got an alert-box with the adress, phonenuer etc.. Pretty cool?..
The reason why i not just use an .asp page to do the search also is that would like to have a search engine for phonenumbers on my pocket pc even if I am offline..
Her is the code. Please look at it and give me some coments! Thanks
<%@LANGUAGE="VBScript"%>
<HTML>
<HEAD>
<TITLE>Make phonelist</TITLE>
<!-- METADATA TYPE="typelib" FILE="c:\WinNT\System32\scrrun.dll" -->
</HEAD>
<BODY>
<%
strTextFile = "d:dir\nam.txt"
strHtmlFile = "d:dir\phonelist.htm"
text="<html><head></head>"&VBcrlf
text=text+"<script language='JavaScript'>nam='"
'create an instance of a FileSytemObject object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject"
'open the text file as a TextStream object
Set objTStream = objFSO.OpenTextFile(strTextFile, ForReading)
'read one line at a time until the end of the file is reached
Do While Not objTStream.AtEndOfStream
text=text+"_"+objTStream.ReadLine
Loop
objTStream.Close
text=text+"'"&VBcrlf
text=text+"function search(){"&VBcrlf
text=text+"var html="&Chr(34)&"<html><head><TITLE>Phone search results</TITLE></head><body>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"<table border=0 cellpadding=2 cellspacing=0><tr><td colspan=2>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"<font face=helvetica>If dialing from the outside use 5169 prefix for Risavika, so that 14-9999 becomes 51 69 99 99. </font>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"</td></tr>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"<tr><td bgcolor='#003366'><font color=beige face='helvetica,arial'><b>Surname</td><td bgcolor='#003366'><font color=beige face='helvetica,arial'><b>First name</td></tr>"&Chr(34)&";"&VBcrlf
text=text+"var re,line,r,s,i=0,n,name; "&VBcrlf
text=text+"if (document.form1.ka[0].checked) {n=0;name='Firstname: ';}"&VBcrlf
text=text+"else {n=1;name='Surname: ';}"&VBcrlf
text=text+"re = form1.searchstring.value;"&VBcrlf
text=text+"re=re.toUpperCase();"&VBcrlf
text=text+"nam=nam.toUpperCase();"&VBcrlf
text=text+"line=nam.split('_');"&VBcrlf
text=text+"for(var j=0;j<line.length;j++){"&VBcrlf
text=text+"s=line[j].split(';');"&VBcrlf
text=text+"if(s[n].indexOf(re)!='-1'){"&VBcrlf
text=text+"i=i+1;"&VBcrlf
'text=text+"html=html+"&Chr(34)&"<tr><td><font face=verdana size=1><a href='javascript: void null()' onclick=\"&Chr(34)&"alert('Name: "&Chr(34)&"+s[0]+"&Chr(34)&" "&Chr(34)&"+s[1]+"&Chr(34)&"\\nDepartment: "&Chr(34)&"+s[2]+"&Chr(34)&"\\nOffice-no.: "&Chr(34)&"+s[3]+"&Chr(34)&"\\nInt.phone: "&Chr(34)&"+s[4]+"&Chr(34)&"\\nPrivate: "&Chr(34)&"+s[5]+"&Chr(34)&"\\nMobile: "&Chr(34)&"+s[7]+"&Chr(34)&"\\nPager: "&Chr(34)&"+s[8]+"&Chr(34)&"\\nAddress: "&Chr(34)&"+s[6]+"&Chr(34)&"')\"&Chr(34)&">"&Chr(34)&"+s[1]+"&Chr(34)&"</a></font></td><td>"&Chr(34)&"+s[0]+"&Chr(34)&"</td></tr>"&Chr(34)&";" &VBcrlf
text=text+"html=html+"&Chr(34)&"<tr><td><font face=verdana size=1><a href='javascript: void null()' onclick=\"&Chr(34)&"confirm('Name: "&Chr(34)&"+s[0]+"&Chr(34)&" "&Chr(34)&"+s[1]+"&Chr(34)&"\\nDepartment: "&Chr(34)&"+s[2]+"&Chr(34)&"\\nOffice-no.: "&Chr(34)&"+s[3]+"&Chr(34)&"\\nInt.phone: "&Chr(34)&"+s[4]+"&Chr(34)&"\\nPrivate: "&Chr(34)&"+s[5]+"&Chr(34)&"\\nMobile: "&Chr(34)&"+s[7]+"&Chr(34)&"\\nPager: "&Chr(34)&"+s[8]+"&Chr(34)&"\\nAddress: "&Chr(34)&"+s[6]+"&Chr(34)&"')\"&Chr(34)&">"&Chr(34)&"+s[1]+"&Chr(34)&"</a></font></td><td>"&Chr(34)&"+s[0]+"&Chr(34)&"</td></tr>"&Chr(34)&";" &VBcrlf
text=text+"}}"&VBcrlf
text=text+"html=html+"&Chr(34)&"</table><p><font face='verdana' size=1><b>"&Chr(34)&"+i+"&Chr(34)&" hits for "&Chr(34)&"+name+form1.searchstring.value+"&Chr(34)&"</b></font></p>"&Chr(34)&";"&VBcrlf
text=text+"html=html+"&Chr(34)&"<p><font face='verdana' size=1>[<a href='phonelist.htm'>Search again</a>]</font></p>"&Chr(34)&VBcrlf
text=text+"html=html+"&Chr(34)&"</html>"&Chr(34)&";"&VBcrlf
text=text+"document.write(html);"&VBcrlf
text=text+"nnn=nnn.value;"&VBcrlf
text=text+"}"&VBcrlf
text=text+"</script>"&VBcrlf
text=text+"<body>"&VBcrlf
text=text+"<h1>Phonebook for SEPNo</h1>"&VBcrlf
text=text+"<font face=helvetica>Search for</font><br>"&VBcrlf
text=text+"<form name='form1' onsubmit='search()'>"&VBcrlf
text=text+"<font face=helvetica>Firstname <input type='radio' name='ka' value='1' checked> Surname<input type='radio' name='ka' value='0'></font><br>"&VBcrlf
text=text+"<input type='text' name='searchstring'>"&VBcrlf
text=text+"<input type='button' value='Search' onclick='search()'>"&VBcrlf
text=text+"</form>"&VBcrlf
text=text+"</body>"&VBcrlf
text=text+"</html>"&VBcrlf
'Response.Write text
'Writes to the file phonelist.htm
Set objTStream = objFSO.OpenTextFile(strHtmlFile, ForWriting, True)
arrLines = Split(text, vbCrLf)
For intLine = 0 To UBound(arrLines)
objTStream.WriteLine arrLines(intLine)
Next
objTStream.Close
%>
<a href="phonelist.htm"> the list </a>
</BODY>
</HTML>
Jørn Arild Andenæs
jaa@jaa.no