ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

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 Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old July 15th, 2003, 10:58 AM
WipedOut WipedOut is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Montreal
Posts: 4 WipedOut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question How to get data from a HTML list to ASP

Hi there,
I was wondering if there is a way to get data from a "select" list (named NIE) to my ASP code so I can generate the right SQL string. Is it possible ?

<SCRIPT LANGUAGE="VBScript">

Sub nie_OnChange()

<%
Dim adoCon
Dim strSQL
Dim rsName
Dim strNIE

'Below is the line causing me problems
strNIE = Document.form.nie.options(Document.form.nie.selectedIndex).text

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=letmein; DBQ=" & Server.MapPath("paie.mdb")

strSQL = "SELECT Employés.* FROM Employés WHERE Employés.[No - Matricule] =" & strNIE
Set rsName = adoCon.Execute("SELECT Employés.* FROM Employés;")
%>
Document.Label2.Caption="<%= rsName("Prénom")%>"
Document.Label1.Caption="<%= rsName("Nom")%>"
<%
adoCon.Close
Set adoCon = Nothing
%>

End Sub

</SCRIPT>

Reply With Quote
  #2  
Old July 15th, 2003, 12:41 PM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to kkong
Hi,

I think your problem is when your trying to pick up values from the objects on the page.

you are using document.form etc but as you are using vbscript you can't use document. You just need to specify the name of the
object. so in your case where you have:

Code:
strNIE = Document.form.nie.options(Document.form.nie.selectedIndex).text 


do this instead.

Code:
strNIE = nie.options(nie.selectedIndex).text 


you'll have to make the changes to the rest as well I would of thought.

hope this helps.

Kong.

Reply With Quote
  #3  
Old July 15th, 2003, 02:02 PM
WipedOut WipedOut is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Montreal
Posts: 4 WipedOut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi ! Thanks for your help, but problem is I still get a blank screen even when I use this simple line in my Subroutine :

<SCRIPT LANGUAGE="VBScript">
Sub nie_OnChange()
<%
Label1.Caption = nie.options(nie.selectedIndex).text
%>
End Sub
</SCRIPT>

But it works this way :

<SCRIPT LANGUAGE="VBScript">
Sub nie_OnChange()
Document.Label1.Caption = Document.form.nie.options(Document.form.nie.selectedIndex).text
End Sub
</SCRIPT>

I don't understand why.

Reply With Quote
  #4  
Old July 15th, 2003, 02:24 PM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to kkong
ok, can you explain these lines a bit better.
it looks like you are setting up the SQL with the variable you want to use, but then the next line you are executing a different bit of SQL and ignoring the top SQL statement.

Code:
strSQL = "SELECT Employés.* FROM Employés WHERE Employés.[No - Matricule] =" & strNIE 
Set rsName = adoCon.Execute("SELECT Employés.* FROM Employés;") 


Kong.

Reply With Quote
  #5  
Old July 15th, 2003, 02:32 PM
WipedOut WipedOut is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Montreal
Posts: 4 WipedOut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Oooops..

Sorry about that !!!

I just copied and pasted that from my current page. As I was currently troubleshooting it, I did a few modifications. It should read :

strSQL = "SELECT Employés.* FROM Employés WHERE Employés.[No - Matricule] =" & strNIE
Set rsName = adoCon.Execute(strSQL)

One thing I don't understand is I get a blank screen on my browser instead of getting the usual error messages, that's why I'm getting a hard time to correct the problem... Anyways even with the lines I showed you in my last message, it still shows a blank screen with the one with the code between <% %>, so this one works fine :

Sub nie_OnChange()
Document.Label1.Caption = Document.form.nie.options(Document.form.nie.selectedIndex).text
End Sub

but not this one :

Sub nie_OnChange()
<%
Label1.Caption = nie.options(nie.selectedIndex).text
%>
End Sub

It's only one line of code and I still get a blank browser screen...

Reply With Quote
  #6  
Old July 15th, 2003, 02:57 PM
kkong's Avatar
kkong kkong is offline
Monkey Magic
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: UK
Posts: 103 kkong User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to kkong
Re: Oooops..

Quote:
Originally posted by WipedOut
[so this one works fine :

Sub nie_OnChange()
Document.Label1.Caption = Document.form.nie.options(Document.form.nie.selectedIndex).text
End Sub

but not this one :

Sub nie_OnChange()
<%
Label1.Caption = nie.options(nie.selectedIndex).text
%>
End Sub

It's only one line of code and I still get a blank browser screen... [/B]


ok the top one works because it's all client script ie VbScript, the bottom one I'm guessing does not work as you are trying to set a client-side object in ASP which is server side language. The server side ASP would of allready been rendered before you get to the client side stuff which is why I think you are getting a blank result.

I could be very wrong but I don't think you can do that.


What I tend to do when building query's for SQL is to capture the
data either via a page reload or a form or something then I
re-call the page ie page.html?var=figureIneed or in a form contents and then using asp extract these and then run the SQL.

Kong.

Reply With Quote
  #7  
Old July 15th, 2003, 03:06 PM
WipedOut WipedOut is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Montreal
Posts: 4 WipedOut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Thanks

Thanks a lot kkong !

I think you are right, makes sense to me. I was wondering if there was a way to do it without any refreshes. Guess I'll have to do it that way. Thanks a bundle !

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > How to get data from a HTML list to ASP


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 3 hosted by Hostway