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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with linked dynamic listbox's

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
US
Hi all,

I tried Link's FAQ on dynamic linked listbox's. But once I select one box - the page refreshes as it should - but box number 2 just stays empty - no matter the record selected in box one.

Anybody run into this?

I've double checked field names, rs names, sql names, menu box names, all seems ok. "Damn the torpedoes, full speed ahead!"

-Adm. James Farragut

Stuart
 
Hey,

sorry for the delay - I did not intend to be offline last night.

I've got the code almost verbatim from the faq. First time the page is loaded it loads everything great - its upon selecting a drop down - when it resubmits - that it goes nuts. - ModelNumbers do start with a Letter.

Here is the sql's


if (Request.Form.Count = 0) then

makeSQL = "SELECT ModelNumber AS description"
makeSQL = makeSQL & " FROM ModelNumber ORDER BY ModelYear DESC, ModelNumber ASC"

modelSQL = "SELECT Short_color AS description"
modelSQL = modelSQL & " FROM Picture ORDER BY modelnumber ASC"

else

'THIS IS A RECURSIVE LOAD
' WE NEED TO SEE WHAT THE USER HAS CHOSEN

curMake = Request.Form("make")
curModel = Request.Form("model")

'NOW WE WILL BUILD OUR DYNAMIC SQL STATEMENT

'LET'S STILL SELECT ALL MAKES, SO THAT THE USER CAN
' SELECT A DIFFERENT ONE IF THEY WISH
makeSQL = "SELECT ModelNumber AS description FROM ModelNumber"
makeSQL = makeSQL & " ORDER BY ModelYear DESC, ModelNumber ASC"

'LET'S ONLY SELECT THE MODELS THAT CORRESPOND TO
' THE USER'S CHOICE
modelSQL = "SELECT Short_color AS description"
modelSQL = modelSQL & " FROM Picture"
modelSQL = modelSQL & " WHERE ModelNumber = '" & curMake & "'"
modelSQL = modelSQL & " ORDER BY Short_Color"

end if

con.Open strCon

makeRS.Open makeSQL, con
modelRS.Open modelSQL, con
%>


Then inside the Head tags.


<SCRIPT LANGAUAGE=javaScript>
//THIS IS THE FUNCTION THAT WILL BE CALLED
// onChange FOR EITHER OF THE LIST BOXES
// ALL IT WILL DO IS SUBMIT THE FORM FOR US

function submitMe(){
document.theForm.submit();
}
</SCRIPT>


Inside the table


<%
'I'M GOING TO USE A SUBPROCEDURE TO WRITE OUT
' OUR SELECTS -- SENDING IT THE APPROPRIATE VARIABLES
' TO WRITE THE PROPER SELECT

call makeSelect(makeRS,curMake,&quot;make&quot;)
call makeSelect(modelRS,curModel,&quot;model&quot;)
%>


and below the </html>


<%
'TAKE OUT THE TRASH
set makeRS = nothing
set modelRS = nothing
set con = nothing

sub makeSelect(lRS,curValue,selectName)

with response

.Write(&quot;<SELECT NAME=&quot; & selectName)
.Write(&quot; onChange=&quot;&quot;submitMe();&quot;&quot;>&quot; & vbcr)

'LET'S PUT A DEFAULT SELECTION IN THAT
' WILL AUTOMATICALLY SHOW IF
' THE USER HAS NOT YET MADE A CHOICE
.Write(&quot;<OPTION VALUE=none>SELECT ONE</OPTION>&quot; & vbcr)

'LOOP THROUGH OUR RECORDSET,
' OUTPUTTING WHATEVER'S THERE
while not lRS.eof
.Write(&quot;<OPTION VALUE=&quot;&quot;&quot; & lRS(&quot;description&quot;) & &quot;&quot;)

'CHECK TO SEE IF THE CURRENT VALUE WAS SELECTED
' BY THE USER AND SELECT IT IF SO
if curValue = lRS(&quot;description&quot;) then
.Write(&quot; selected&quot;)
end if

.Write(&quot;>&quot; & lRS(&quot;description&quot;) & &quot;</OPTION>&quot; & vbcr)

lRS.MoveNext
wend

.Write(&quot;</SELECT>&quot;)

end with

end sub
%>


Thank you for your assistance &quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
ahhh heck, going through trying to debug I noticed two extra &quot;&quot; was messin itup.

got it.

&quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
Problems are only problems until you try to show it to someone else, and bugless code is only bugless under the same scenario :)
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top