Forum Moderators: open
You are going to need to, at least, refresh the page - this cannot be done within a single document.
In order to begin the database query, you are going to need to run some server side script, and in order to do this you need to send a request to the server by going to another (or the same) ASP page.
<script language="javaScript">
<!--
function MakeUpper(i)
{
i.value = i.value.toUpperCase();
}
//-->
</script>
and then do I add
return;
as the last line under the new call to the other ASP Page in this function?...>>
1. Preload a javascript array with the reference data and populate the <td> on inputbox.onBlur()
2. There is a remote scripting option - your javascript opens up an invisible IFrame and the IFrame content is an ASP page that extracts the data from the database and calls a function back on the original page to do whatever you want with the data - this does work but you need to really know what you are doing (search for 'remote scripting iframe' on Google and take the top search result for some example code)
3. Stop trying to reproduce desktop apps/functionality on a web application. The programming methods are different and the design should be different from the desktop. Of course, the people who ask (and pay) for these apps don't listen to this arguement so you end up giving them slower/more flaky code in an attempt to reproduce the desktop.
</style>
<script language="javaScript">
<!--
function MakeUpper(i)
{
i.value = i.value.toUpperCase();
document.WPQTT.submit();
}
//-->
</script>
the WPQTT is the name of the current form which has this script in it....I get an error "object doesn't support this property or method" on the document word in the script.
Where do I reference the extra ASP page and how do I forward the value in a var with that submit line?..>>>
I'm using code i found searching the web... its..
<SCRIPT LANGUAGE="JAVASCRIPT" src="exchanger.js"></SCRIPT>
<SCRIPT LANGUAGE="JAVASCRIPT">
var theBuffer;
//call this function in page onload event handler
function initialize()
{
theBuffer = new exchanger("myframe");
}
//call this function when data needs to be sent to server
function sendDataToServer(data)
{
theBuffer.sendData("rx.asp?" + data);
}
//call this function to check what the server returns.
function showReturnData()
{
document.all("1").innerText = ' '+ theBuffer.retrieveData("myNewData");
}
</SCRIPT>
</head>
<Body onload="initialize()">
<IFRAME name=myframe style="width:4000;height:200"></IFRAME>
<script type="text/javaScript">
function MakeUpper(i)
{
i.value = i.value.toUpperCase();
var test =i.value;
sendDataToServer("data="+test);
}
</script>
and the exchjanger script is...
function UserAgent()
{
var b=navigator.appName.toUpperCase();
if (b=="NETSCAPE") this.b="ns";
else if (b=="MICROSOFT INTERNET EXPLORER") this.b="ie";
else if (b=="OPERA") this.b="op";
else this.b=b;
this.version=navigator.appVersion;
this.v=parseInt(this.version);
this.ns=(this.b=="ns" && this.v>=4);
this.ns4=(this.b=="ns" && this.v==4);
this.ns5=(this.b=="ns" && this.v==5);
this.ie=(this.b=="ie" && this.v>=4);
this.ie4=(this.version.indexOf('MSIE 4')>0);
this.ie5=(this.version.indexOf('MSIE 5')>0);
this.ie55=(this.version.indexOf('MSIE 5.5')>0);
this.ie6=(this.version.indexOf('MSIE 6')>0);
this.op = (this.b=="op");
this.op4 = (this.b=="op" && this.v==4);
this.op5 = (this.b=="op" && this.v==5);
}
at=new UserAgent();
//if you want to create the frame or layer dynamically, do not
//specify a name, do something like this, new exchanger();
function exchanger(name)
{
//hold the dynamically created iframe or layer
this.lyr = null;
//to remember if the iframe or layer is created dynamically.
this.isDynamic = false;
this.name=name¦¦"";
//this.fakeid=0;
if (name == null ¦¦ name=="")
{
this.isDynamic = true;
this.create();
}
else
{
this.name=name;
if (at.ns4)
{
this.lyr = window.document.layers[this.name];
}
}
}
//this function should not be called directly
exchanger.prototype.create=function()
{
if (at.ns4)
{
this.lyr=new Layer(0);
this.visibility = "hide";
}
else if (at.ie ¦¦ at.ns5)
{
this.lyr=document.createElement("IFRAME");
this.lyr.width=0;
this.lyr.height=0;
this.lyr.marginWidth=0;
this.lyr.marginHeight=0;
this.lyr.frameBorder=0;
this.lyr.style.visibility="hidden";
this.lyr.style.position="absolute";
this.lyr.src="";
this.name="tongIFrame"+window.frames.length;
//this will make IE work.
this.lyr.setAttribute("id",this.name);
//this will make netscape work.
this.lyr.setAttribute("name",this.name);
document.body.appendChild(this.lyr);
}
}
exchanger.prototype.sendData=function(url)
{
//this.fakeid += 1;
var newurl = "";
if (url.indexOf("?") >= 0)
newurl = url
// + "&fakeId" + this.fakeid;
else
newurl = url
// + "?fakeId" + this.fakeid;
if (this.isDynamic¦¦at.ns4)
this.lyr.src=newurl;
else
{
if (at.ie ¦¦ at.ns5 ¦¦ at.op)
{
window.frames[this.name].document.location.replace(newurl);
}
}
}
exchanger.prototype.retrieveData=function(varName)
{
if (at.ns4)
{
return eval("this.lyr." + varName);
}
else if (at.ie ¦¦ at.ns5 ¦¦ at.op)
{
return eval("window.frames['" + this.name + "']." + varName);
}
}
and my RX.ASP is...
<%response.buffer=true%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd">
<!--Program design started 14th January 2003-->
<html>
<head>
<!--#include file="adovbs.inc"-->
<meta http-equiv="content-type" content="text/html;charset=windows-1252" />
<title></title>
</head>
<body>
<script language="javascript">
myNewData = '<%=request.querystring("data")%>';
</script>
<%
Set ConnDB = Server.CreateObject("ADODB.Connection")
ConnDB.Open "ShepNims"
Set ShepRS = Server.CreateObject("ADODB.Recordset")
Query ="SELECT * FROM QTT WHERE ItemCode=N68"
ShepRS.Open Query,ConnDB,adOpenStatic, adLockOptimistic
myNewData = ShepRS("Description")
ConnDB.close
Set ShepRS = Nothing
Set ConnDB = Nothing
%>
<table border="1">
<tr><td><%=nyNewData%></td></tr></table>
<script language="javascript">
window.parent.showReturnData(myNewData);
</script>
</body>
</html>
sorry theres so much code here, hope u can pick out the necessary bits......>>
set the action of your form to the same page.
in your onChange (or onBlur) method, make uppers, then submit the form.
Process your read, and show the page back with the database data.
You'll need something like this is the ASP section:
query = false
if cstr(Request.Form("submit")) <> "undefined" then
run query
query = true
end if
Then, down below hide the rows with DB data using the boolean variable.
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/Shepwww/rx.asp, line 17
and this is the ASP code which opens the DB and looks for the inputted text in a tabl field...my code to do this works fine on every other ASP Page it is....
<%
set ConnDB = Server.CreateObject("ADODB.Connection")
ConnDB.Open "ShepNims"
set ShepRS = Server.CreateObject("ADODB.Recordset")
query="SELECT * FROM QTT WHERE ItemCode=N68"
ShepRS.Open query,ConnDB,adOpenStatic, adLockOptimistic
myNewData=ShepRS("description")
ConnDB.close
Set ShepRS = Nothing
Set ConnDB = Nothing
%>
where I'm just trying to get it to run by using N68 embedded in this code..this will be the variable containing the user input...on ur point of a target......would this be the target for the RX.ASP form sent to the IFRAME or the target of the hoem ASP page which the user is filling in...its ' action=' is to itself.....>>>
Why make it more complicated for yourself and the user? Keep it simple and functional and your users will hug you.