Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

Multiple lists in forms - inserting records

Posted 29 Nov 2002 09:34:14
1
has voted
29 Nov 2002 09:34:14 john doe posted:
Hi.

I've made an insert-record form with two list-boxes, one being the main category, the next being an undercategory of the first. What I want is only to show the undercategory items that have the the selected "parent" in the main category. So if I choose, for instance "Boats" for main category, I only get different kind of boats in the undercategory.

I've tried various ways, sorting recordsets, manipulating access and so on, but it won't work.

What to do? Is it in access, in the default value of the lists, in the recordsets, or do I need a javascript.

<i>Any help is valued.</i>

Supertorjus

Replies

Replied 29 Nov 2002 14:22:23
29 Nov 2002 14:22:23 Vince Baker replied:
There are two ways of achieving this:

1. Filter the second recordset by a common value in the first. This does require the page to refresh though and that can be annoying for the user if they have already entered data into the form.

Here is a link to achieve no.1
www.dmxzone.com/showDetail.asp?TypeId=2&NewsId=3218

2. This is my prefered way and as you say it does require javascript:

Here is a link for no.2
www.macromedia.com/support/ultradev/ts/documents/client_dynamic_listbox.htm



Regards
Vince

Response.write("The best line of code you can ever use"

VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 04 Dec 2002 17:40:49
04 Dec 2002 17:40:49 sup ert replied:
Thanks a lot. Works like a charm!
Replied 03 Feb 2004 15:30:44
03 Feb 2004 15:30:44 Matt Jukes replied:
I have a small problem with the tutorial that this post points to. At one point you need to change the name for the child boxes recordset...How and where do I put the name. I know this is probably a stupid question but I am new to javascript. Thanks in advance
Matt
Replied 03 Feb 2004 21:31:11
03 Feb 2004 21:31:11 sup ert replied:
Hi.
This is a while back, so ... I used the first method, with two forms in one page and 'advanced conditional regions' (downloadable extention) which only shows the first in the beginning, and only the second in the end.

The first form (form2 underneath) gives you the categories using an listbox and repeated region, and sends the chosen category to the same page (reloads). You then use Request. QueryString to sort the second category. The main category gets its value in the insertform (form1 underneath) the same way, but hidden.

To sum it up: the first time the category is read from database, the second time from the addressbar. This is how I remember it through my written pages...

Supert.


<pre id=code><font face=courier size=2 id=code>

&lt;% if Request.QueryString("MoteKat" = "" then ' Adv Conditional Region %&gt;

&lt;form name="form2" id="form2" method="get" action="NySak.asp?MoteKat=&lt;%=(rsMoteKat.Fields.Item("Moter_kat_navn".Value)%&gt;"&gt;
&lt;table border="0" align="center" cellpadding="3"&gt;
&lt;tr&gt;
&lt;td&gt;Choose category:&lt;/td&gt;
&lt;td&gt; &lt;select name="MoteKat" id="select"&gt;
&lt;option value="" selected&gt;Choose...&lt;/option&gt;
&lt;%
While (NOT rsMoteKat.EOF)
%&gt;
&lt;option value="&lt;%=(rsMoteKat.Fields.Item("Moter_kat_navn".Value)%&gt;"&gt;&lt;%=(rsMoteKat.Fields.Item("Moter_kat_navn".Value)%&gt;&lt;/option&gt;
&lt;%
rsMoteKat.MoveNext()
Wend
If (rsMoteKat.CursorType &gt; 0) Then
rsMoteKat.MoveFirst
Else
rsMoteKat.Requery
End If
%&gt;
&lt;/select&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="submit" name="Submit" value="Submit" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;% end if ' Request.QueryString("MoteKat" = "" %&gt;


------------



&lt;% if Request.QueryString("MoteKat" &lt;&gt; "" then ' Adv Conditional Region %&gt;
&lt;form method="POST" action="&lt;%=MM_editAction%&gt;" name="form1"&gt;
&lt;table align="center"&gt;
&lt;tr valign="baseline"&gt;
&lt;td nowrap align="right"&gt;Category:&lt;/td&gt;
&lt;td&gt; &lt;input name="MoteKategori" type="hidden" id="MoteKategori" value="&lt;%= Request.QueryString("MoteKat" %&gt;" /&gt;
&nbsp;&nbsp; &lt;%= Request.QueryString("MoteKat" %&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr valign="baseline"&gt;
&lt;td nowrap align="right"&gt;Møtedato:&lt;/td&gt;
&lt;td&gt; &lt;select name="MoteDato"&gt;
&lt;%
While (NOT rsMote.EOF)
%&gt;
&lt;option value="&lt;%=(rsMote.Fields.Item("MoteDato".Value)%&gt;" &lt;%If (Not isNull((rsMote.Fields.Item("MoteKat".Value))) Then If (CStr(rsMote.Fields.Item("MoteDato".Value) = CStr((rsMote.Fields.Item("MoteKat".Value))) Then Response.Write("SELECTED" : Response.Write(""%&gt; &gt;&lt;%=(rsMote.Fields.Item("MoteDato".Value)%&gt;&lt;/option&gt;
&lt;%
rsMote.MoveNext()
Wend
If (rsMote.CursorType &gt; 0) Then
rsMote.MoveFirst
Else
rsMote.Requery
End If
%&gt;
&lt;/select&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr valign="baseline"&gt;
&lt;td nowrap align="right"&gt;Case no.:&lt;/td&gt;
&lt;td&gt; &lt;input type="text" name="SakNr" value="" size="5"&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr valign="baseline"&gt;
&lt;td nowrap align="right"&gt;Sak år:&lt;/td&gt;
&lt;td&gt; &lt;select name="SakAAr"&gt;
&lt;option value="2004" selected&gt;2004&lt;/option&gt;
&lt;option value="2003" &gt;2003&lt;/option&gt;

&lt;/select&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr valign="baseline"&gt;
&lt;td nowrap align="right"&gt;&nbsp;&lt;/td&gt;
&lt;td&gt; &lt;input name="submit" type="submit" value="Legg til" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;input type="hidden" name="MM_insert" value="form1"&gt;
&lt;/form&gt;
&lt;% end if ' Request.QueryString("MoteKat" &lt;&gt;"" %&gt;
</font id=code></pre id=code>

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I have a small problem with the tutorial that this post points to. At one point you need to change the name for the child boxes recordset...How and where do I put the name. I know this is probably a stupid question but I am new to javascript. Thanks in advance
Matt
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Reply to this topic