JavaScript:
function showCustomer(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getcustomer.asp?q="+str,true);
xmlhttp.send();
}
======================
ASP:
<%
response.expires=-1
sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID="
sql=sql & "'" & request.querystring("q") & "'"
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs=Server.CreateObject("ADODB.recordset")
rs.Open sql,conn
response.write("<table>")
do until rs.EOF
for each x in rs.Fields
response.write("<tr><td><b>" & x.name & "</b></td>")
response.write("<td>" & x.value & "</td></tr>")
next
rs.MoveNext
loop
response.write("</table>")
%>
Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts
Wednesday, December 08, 2010
AJAX Database Example
All Javascript in one page
Contents: Review: Review, Allocation, Simple Examples; JavaScript Language: Values, Data type conversion, Variables, Literals, Expressions, Operators, Statements, Functions, Built-in Functions, Objects, Built-in Objects, Event; Built-in JavaScript Objects: Root (Root Properties, Root Methods), Array (Array Description, Array Properties, Array Methods), Boolean (Boolean Description), Data (Data Description,Data Methods), Function (Function Description), Image (Image Description,Image Properties), Math (Math Description, Math Properties, Math Methods), Number (Number Description,Number Properties), String (String Description,String Properties,String Methods); Other: Other; Similar Sites: MANUAL, Cheat sheets, HTML, CSS, XML, DTD, JavaScript, W3C DOM, SQL, SSI, Tell a friend, Free Icons, Itlibitum, Corp.. |
Monday, February 28, 2005
JAVASCRIPT: Trim
String.prototype.trim = function() {
// skip leading and trailing whitespace
// and return everything in between
var trimmedString = this
trimmedString = trimmedString.replace(/^\s+/,"");
trimmedString = trimmedString.replace(/\s+$/,"");
return trimmedString;
}
//using:
var trimmed_str=field_name.value.trim();
// skip leading and trailing whitespace
// and return everything in between
var trimmedString = this
trimmedString = trimmedString.replace(/^\s+/,"");
trimmedString = trimmedString.replace(/\s+$/,"");
return trimmedString;
}
//using:
var trimmed_str=field_name.value.trim();
JAVASCRIPT: createPopup
var macamMailPopup = window.createPopup();
function openMacamMailPopup() {
var popupBody = macamMailPopup.document.body;
popupBody.style.backgroundColor = "lightyellow";
popupBody.style.border = "solid black 1px";
popupBody.innerHTML = document.getElementById("macamMailPopupHtml").innerHTML;
macamMailPopup.show(0, 0, 250, 85, document.getElementById("macamMailComment"));
}
function openMacamMailPopup() {
var popupBody = macamMailPopup.document.body;
popupBody.style.backgroundColor = "lightyellow";
popupBody.style.border = "solid black 1px";
popupBody.innerHTML = document.getElementById("macamMailPopupHtml").innerHTML;
macamMailPopup.show(0, 0, 250, 85, document.getElementById("macamMailComment"));
}
Subscribe to:
Posts (Atom)