HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 20th, 2004, 11:08 AM
davidcat davidcat is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 21 davidcat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry javascript query problems

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();
%>

Reply With Quote
  #2  
Old March 20th, 2004, 07:48 PM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 6
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).

Reply With Quote
  #3  
Old March 21st, 2004, 05:59 AM
davidcat davidcat is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 21 davidcat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi, is there anything like this in vbscript?

code:

<script language="javascript">
document.formname.t1.value = "<%=rsAd.Fields("SomeField2") %>";
</script>

Reply With Quote
  #4  
Old March 21st, 2004, 06:49 AM
davidcat davidcat is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 21 davidcat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old March 21st, 2004, 10:32 AM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 6
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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > javascript query problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT