|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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> |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
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... |
|
#6
|
||||
|
||||
|
Re: Oooops..
Quote:
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. |
|
#7
|
|||
|
|||
|
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 ! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > How to get data from a HTML list to ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|