|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all,
Ive got a problem, in my webpage i have a button, when pressed i want it to connect to an access db and write the result(only 2 records) to two seperate text boxes. I have never used jscript, but am not too bad at asp. please help. I have this code but i dont want to response.write. I want to write to a text box, one called Indoor one called outdoor. Any help would be appreciated thanks David var strConnect = "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=c:/Inetpub/wwwroot/TemperatureDB.mdb;"; oConn=Server.CreateObject("ADODB.Connection"); oConn.Open(strConnect); var strSQL = "SELECT ALL FROM MyTable;"; var rsAd=oConn.Execute(strSQL); Response.Write("First row is "+ rsAd.Fields("SomeField") ) oConn.Close(); %> |
|
#2
|
||||
|
||||
|
A response.write would be very easy:
<input type="text" name="t1" value="<%=rsAd.Fields("SomeField1") %>"> <input type="text" name="t2" value="<%=rsAd.Fields("SomeField2") %>"> With javascript you can do something like this once the html loads: <script language="javascript"> document.formname.t1.value = "<%=rsAd.Fields("SomeField2") %>"; </script> Either way, you're going to have to response.write the value into the Javascript code because the javascript code (client-side) can't directly interact with ASP (server-side). |
|
#3
|
|||
|
|||
|
Hi, is there anything like this in vbscript?
code: <script language="javascript"> document.formname.t1.value = "<%=rsAd.Fields("SomeField2") %>"; </script> |
|
#4
|
|||
|
|||
|
Ahhhhhhhhhh , this is killlling me!!!
Right this is the code ive now got in the html to display the records: <% response.write (Outdoor) %> <% response.write (Indoor) %> Indoor and Outdoor are called from an included file whose code is: <% Set MyConn = Server.CreateObject("ADODB.Connection") MdbFilePath = Server.MapPath("TemperatureDB.mdb") MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";" SQL_query = "SELECT * FROM MyTable" Set RS = MyConn.Execute(SQL_query) WHILE NOT RS.EOF %> <%Outdoor = RS("Outdoor") %> <%Indoor = RS("Indoor") %> <% RS.MoveNext WEND MyConn.close %> And the code to refresh these records on the webpage is: <form name="form1" method="post" action=""> <input type="button" name="Submit" value="Submit" onClick="<%=RS("Outdoor")%>"> </form> Im getting this error message on the webpage: Microsoft VBScript runtime error '800a000d' Type mismatch: 'RS' /controlpanel.asp, line 80 |
|
#5
|
||||
|
||||
|
Declare and initialize RS.
Set RS = Server.CreateObject("ADODB.Recordset") I didn't see that in your included code. And yes, you can set textbox values using VBScript. http://www.soldierx.com/books/Late%...htm#FormObjects |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > javascript query problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|