Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get value from list box for asp code

Status
Not open for further replies.

JennB

Programmer
Feb 3, 2002
29
CA
Hi, I am really having problems with this and I don't know why it's so hard. I have a page with a dynamic menu. When the user clicks on the menu I want to get all the information from the database on the field they selected and put this information into text boxes.

in the <% %> brackets it doesn't seem to recognize the value of my select box (frmArticles.select.value) however if I put it in <Script Language=&quot;VBSCRIPT> </SCRIPT> it does recognize this value. Is there some different code to get the value from a list menu when using the in the <% %> brackets? The problem is that if I use the other synatax the server connection doesn't work.

My code looks like this. Everything works except that it doesn't recognize the value of frmArticles.select.value :

<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
....

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function Fillboxes()
{
<%
set GetArticle = Server.CreateObject(&quot;ADODB.Recordset&quot;)
GetArticle.ActiveConnection = MM_enerchihealth_STRING
GetArticle.Source = &quot;SELECT * FROM dbo.tblArticle where fldArticleNum = &quot; & frmArticles.select.value
GetArticle.CursorType = 0
GetArticle.CursorLocation = 2
GetArticle.LockType = 3
GetArticle.Open()
GetArticle_numRows = 0
response.write &quot;ArticleID: &quot; & articleid
%>
document.frmInsert.fldTitle2.value = &quot;<%=(GetArticle.Fields.Item(&quot;fldTitle&quot;).Value)%>&quot;;
}
</SCRIPT>

Thanks so much for your help. :)
 
i believe you are confusing client-side code with server-side code.

anything within the <% %> brackets is processed on the server, before the page is even sent to the client. once it gets sent to the client, the server processing ends.

anything within the <script language=&quot;&quot;> brackets is client-side code, which is processed by the client's browser after the page has been generated on the server and delivered to the client. thus, you will never be able to access a database using client-side code. database activity must be handled by server-side processed code, before the page is delivered.

so, in your case, whatever the client selects in the dropbox will need to be POSTed to the server in a <form>. you can then check the values of what was posted using the Request.Form object, do your database stuff, then re-generate a new, second page to be delivered using server-side code. this is the familiar &quot;first-page form, second-page results&quot; scheme that is the web.

good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top