I'm quite new to ASP, so please bear with me.
I've got a simple list that displays informations from a database. What I want to be able to do is select an item from the list and for it to fill in the rest of the details on the screen?
Hows it done?
Printable View
I'm quite new to ASP, so please bear with me.
I've got a simple list that displays informations from a database. What I want to be able to do is select an item from the list and for it to fill in the rest of the details on the screen?
Hows it done?
Place the drop down list on a form, set the forms action to reload the current page. Pass the value from the dropdown list to an SQL query:
Code:<form METHOD="POST" ACTION="parkes.asp" >
<SELECT NAME="Users" SIZE="1">
<OPTION VALUE="Bubba">Bubba
<OPTION VALUE="Parkes">Parkes
</SELECT>
<INPUT TYPE="SUBMIT" NAME="ACTION" VALUE="Select User">"
</form>
Elsewhere in your asp........
If Request("Action") = "Select User" Then
'run your sql query like
"Select * from tblUsers where username = '" & request("users") & "'"
End if
I'd like to be able to do this without reloading the page. I've seen it done, just cannot get to the code?:(
You can't post new data too a page without reloading/refreshing it.
Parkes,
I think Bubba is right. You'd have to reload the page. Except for one thing: if you're right about seeing it before, then it was probably XML and XSL. That's the beauty of XML - you pull all the data in at once (instead of multiple trips to the database every time a new selection is made), then you can sort the data right there on the screen. XML is actually not that hard. Check it out. It is probably what you need.
If you had the stuff stored in say a client side array, then you could update it dynamically. But it is not possible to get info from the DB on the fly like that.
It would have to be a small set of data too. Otherwise your page will be huge when it is downloaded. I have used the arrays technique to have cascading dropdowns.. one selection filters the next etc..
But if you have more than say 20 possibilities in the first dropdown, I wouldn't use this method.. An XML doc would be another answer..
conn.open
set rsup=server.CreateObject ("adodb.recordset")
sSQL="select * from prodcat "
rsup.Open sSQL,conn,adOpenStatic,adLockPessimistic ,adcmdtext
session("prodid")=Request.QueryString("id")
prodid=session("prodid")
if prodid="" then
prodid="select"
end if
<% Response.Write "<select name='menu1' onChange =MM_jumpMenu('self',this,0)>"
Response.Write "<option selected>" & prodid & "</option>"
while not rsup.EOF
Response.Write "<option value='receivingchallan.asp?id="& rsup("styleno")& "' >" & rsup("styleno") & "</option>"
rsup.MoveNext
wend
Response.Write "</select>"
rsup.Close
set rsup=nothing
%>
Elsewhere in your asp........
If Request.querysting("id")<>"select" then
'run your sql query like
"Select * from products where prodid = '" prodid & "'"
End if
<head>
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
</script>
</head>
I don't really see how that will work...
Its not the game of KIDS
What the hell is that supposed to mean?
adeelahmed: Your code does nothing to address his problem
parkes: If you have a large number of options in the first select that would effect the other controls, use an XML file and load it into the document on the client side. If not, then build client side arrays to hold all of your data and just switch between the values in the onchange event of the select tag.
Apologize!