Don Oldenburg
|
| Posted: 08/20/2001, 1:49 PM |
|
Okay -- I'm getting very frustrated...
Can someone send me their code for a dynamic listbox in ASP? I need to know
what the header/footer code is, as well as any events... I'm having a
terrible time getting this to function within CC.. I've got a working model
OUTSIDE of CC, but no cant implement it into CC.
HELP!
|
|
|
 |
Megan Garrison
|
| Posted: 08/20/2001, 3:58 PM |
|
hi Dan ~ here is what works for me, BUT it does not work in netscape and the
dependent list boxes MUST be on a page that is not getting any
variables/values passed to it via URL
dependent list boxes for country (canada & us) and state/province. I have a
country table (tbleCountries) with a country_id and country fields and I
have a locations table (tblLocations) with location_id, state, and
country_id fields.
I put this code in the forms Events, under Open:
'start
set rs = cn.execute("select [c].[country_id] as catid,[c].[country] as
catname from [tblCountries] c where [country_id] <> '99999';")
set subrs = Server.CreateObject("ADODB.Recordset")
while not rs.eof
set subrs = cn.execute ("select location_id as my_location_id,state as name
from [tblLocations] where country_id= '" & rs(0) & "'" )
while not subrs.eof
name = subrs(1)
id = subrs(0)
subrs.MoveNext
if subrs.eof then
SetVar "subcat" , """" & name & "#" & id & """"
else
SetVar "subcat" , """" & name & "#" & id & ""","
end if
Parse "subcats",true
wend
subrs.close
SetVar "cat" , rs(1) & "#" & rs(0)
Parse "cats",true
SetVar "subcats",""
rs.MoveNext
wend
rs.close
'end
and I put this code under the footer part of the same form (form is named
SearchGroups)
<code>
<script language="Javascript">
var cats = new Array();
<!--Begincats-->
cats["{cat}"] = new Array(
<!--Beginsubcats-->
{subcat}
<!--Endsubcats-->
);
<!--Endcats-->
var k=0;
for (i in cats) {
cat_name_id = i.toString().split("#");
document.forms["SearchGroups"].country_id.options[k] = new Option
cat_name_id[0] , cat_name_id[1])
k=k+1;
}
/*for (i in cats) {
cat_name_id = i.toString().split("#");
document.forms["SearchGroups"].country_id.options[k] = new Option
cat_name_id[0] , cat_name_id[1])
k=k+1;
}*/
function set_subcat() {
var lbopt = document.SearchGroups.country_id.options;
var arr = cats[lbopt[lbopt.selectedIndex].text];
key = lbopt[lbopt.selectedIndex].text + "#" +
lbopt[lbopt.selectedIndex].value;
for (i=document.SearchGroups.my_location_id.options.length; i >=0 ; i--) {
document.SearchGroups.my_location_id.options=null;
}
for (i=0; i < cats[key].length; i++) {
subcat_name_id = cats[key].split("#");
document.SearchGroups.my_location_id.options = new
Option(subcat_name_id[0],subcat_name_id[1])
}
}
document.all["country_id"].onchange = set_subcat;
function parseQueryString (str) {
str = str ? str : location.search;
var query = str.charAt(0) == '?' ? str.substring(1) : str;
var args = new Object();
if (query) {
var fields = query.split('&');
for (var f = 0; f < fields.length; f++) {
var field = fields[f].split('=');
args[unescape(field[0].replace(/\+/g, ' '))] =
unescape(field[1].replace(/\+/g, ' '));
}
}
return args;
}
file://restore listbox settings
var args = parseQueryString ();
for (var arg in args) {
var opt = document.SearchGroups.elements[arg].options;
for (i=0; i < opt.length; i++) {
file://alert (opt.value + " - "+ args[arg]);
if (opt.value == args[arg])
opt.selected = true;
break; }
}
}
set_subcat();
</script>
</code>
Then in the "Country" and "State" fields, set for listbox, set the List
properties with List of Values as 1;dummy (no join at all)
I have not tried to post code here so In case the above does not show, I am
making a txt file attachment
hope this helps, ~Megan
PS if you ever come up with something that works in netscape or when
variables are being transferred< I'd love to have the code.
begin 666 dependent_listbox.txt
M22!P=70@=&AI<R!C;V1E(&EN('1H92!F;W)M<R!%=F5N=',L('5N9&5R($]P
M96XZ#0H-"B=S=&%R= T*#0H-"G-E="!R<R ](&-N+F5X96-U=&4H(G-E;&5C
M="!;8UTN6V-O=6YT<GE?:61=(&%S(&-A=&ED+%MC72Y;8V]U;G1R>5T@87,@
M8V%T;F%M92!F<F]M(%MT8FQ#;W5N=')I97-=(&,@=VAE<F4@6V-O=6YT<GE?
M:61=(#P^("<Y.3DY.2<[(BD-"@T*<V5T('-U8G)S(#T@4V5R=F5R+D-R96%T
M94]B:F5C="@B041/1$(N4F5C;W)D<V5T(BD-"@T*=VAI;&4@;F]T(')S+F5O
M9@T*#0IS970@<W5B<G,@/2!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N9" B4W1A=&4B(&9I96QD
M<RP@<V5T(&9O<B!L:7-T8F]X+"!S970@=&AE($QI<W0@<')O<&5R=&EE<R!W
M:71H($QI<W0@;V8@5F%L=65S(&%S(#$[9'5M;7D@*&YO(&IO:6X@870@86QL
#*0T*
`
end
|
|
|
 |
Jason Charette
|
| Posted: 08/21/2001, 5:37 PM |
|
If you don't menu using a "menu" page (as opposed to grid or record, where
this technique is trickier), let me know - I'm pretty confident I've got a
method of achieving this.
Jason
"Don Oldenburg" <don.oldenburg@cacmnet.com> wrote in message
news:9lrt4j$t6e$1@news.codecharge.com...
> Okay -- I'm getting very frustrated...
>
> Can someone send me their code for a dynamic listbox in ASP? I need to
know
> what the header/footer code is, as well as any events... I'm having a
> terrible time getting this to function within CC.. I've got a working
model
> OUTSIDE of CC, but no cant implement it into CC.
>
> HELP!
>
>
|
|
|
 |
kmc
|
| Posted: 08/21/2001, 9:08 PM |
|
Jason,
Lots of folks would like to see your method.
I want to use in Search forms, record forms and menu.
Every hint and tip welcomed here.
kmc
"Jason Charette" <jasoncharette@hotmail.com> wrote in message
news:9luurc$4f4$1@news.codecharge.com...
> If you don't menu using a "menu" page (as opposed to grid or record, where
> this technique is trickier), let me know - I'm pretty confident I've got a
> method of achieving this.
>
> Jason
|
|
|
 |
Jason Charette
|
| Posted: 08/22/2001, 3:41 AM |
|
1. Create a menu, and add one item, leave it as label. This will be your
dropdown. (Don't worry, I'm not crazy - hold on).
2. In form properties, events, before show, you will put all of your code to
generate the drop-down, but the tricky part is that you MUST treat this code
as a string. In other words, it must have name assignment(in this case,
let's use $thistemp), if there are quotes, you may have to escape them, and
you will certainly have to surround your code with quotes (example below).
Then add these two lines:
$tpl->set_var("THISISMYCODE", $thistemp);
$tpl->parse("THISISMYCODE", false);
3. In the menu form, past the following into your caption:
<!--BeginTHISISMYCODE-->
{THISISMYCODE}
<!--EndTHISISMYCODE-->
4. Generate page, sit back, and enjoy!
Example using PHP, but should work with anything:
Events, before show:
$thistemp = "<ul><li>Howdy!<BR><li>This is a second item!<BR><li>Now I am
tired of this!<br></ul>";
$tpl->set_var("THISISMYCODE", $thistemp);
$tpl->parse("THISISMYCODE", false);
-- Remember to insert the block in step three, and if I haven't forgotten
anything, it'll work.
Cheers, and hope this helps.
Many thanks to the CC techsupport guys, and especially to Alex, for this
one...
Jason.
"kmc" <kmc@tasmail.com> wrote in message
news:9lvb89$obh$1@news.codecharge.com...
> Jason,
>
> Lots of folks would like to see your method.
> I want to use in Search forms, record forms and menu.
> Every hint and tip welcomed here.
> kmc
>
> "Jason Charette" <jasoncharette@hotmail.com> wrote in message
>news:9luurc$4f4$1@news.codecharge.com...
> > If you don't menu using a "menu" page (as opposed to grid or record,
where
> > this technique is trickier), let me know - I'm pretty confident I've got
a
> > method of achieving this.
> >
> > Jason
>
>
>
|
|
|
 |
Jason Charette
|
| Posted: 08/22/2001, 4:58 AM |
|
Allow me to amend that - $thistemp should contain the HTML that your code
generates - not your code itself! Sorry about that. Teach me to answer these
things, first thing in the morning.... :)
J.
"Jason Charette" <jasoncharette@hotmail.com> wrote in message
news:9m028d$v5f$1@news.codecharge.com...
> 1. Create a menu, and add one item, leave it as label. This will be your
> dropdown. (Don't worry, I'm not crazy - hold on).
>
> 2. In form properties, events, before show, you will put all of your code
to
> generate the drop-down, but the tricky part is that you MUST treat this
code
> as a string. In other words, it must have name assignment(in this case,
> let's use $thistemp), if there are quotes, you may have to escape them,
and
> you will certainly have to surround your code with quotes (example below).
> Then add these two lines:
> $tpl->set_var("THISISMYCODE", $thistemp);
> $tpl->parse("THISISMYCODE", false);
>
> 3. In the menu form, past the following into your caption:
>
> <!--BeginTHISISMYCODE-->
> {THISISMYCODE}
> <!--EndTHISISMYCODE-->
>
> 4. Generate page, sit back, and enjoy!
>
> Example using PHP, but should work with anything:
>
> Events, before show:
>
> $thistemp = "<ul><li>Howdy!<BR><li>This is a second item!<BR><li>Now I am
> tired of this!<br></ul>";
> $tpl->set_var("THISISMYCODE", $thistemp);
> $tpl->parse("THISISMYCODE", false);
>
> -- Remember to insert the block in step three, and if I haven't forgotten
> anything, it'll work.
>
> Cheers, and hope this helps.
>
> Many thanks to the CC techsupport guys, and especially to Alex, for this
> one...
>
> Jason.
>
>
> "kmc" <kmc@tasmail.com> wrote in message
>news:9lvb89$obh$1@news.codecharge.com...
> > Jason,
> >
> > Lots of folks would like to see your method.
> > I want to use in Search forms, record forms and menu.
> > Every hint and tip welcomed here.
> > kmc
> >
> > "Jason Charette" <jasoncharette@hotmail.com> wrote in message
> >news:9luurc$4f4$1@news.codecharge.com...
> > > If you don't menu using a "menu" page (as opposed to grid or record,
> where
> > > this technique is trickier), let me know - I'm pretty confident I've
got
> a
> > > method of achieving this.
> > >
> > > Jason
> >
> >
> >
>
>
|
|
|
 |
Frank Rocco
|
| Posted: 08/22/2001, 10:47 AM |
|
I tried this and cannot get it to work.
In the Events Before Show I entered:
$thistemp = "<ul><li>Howdy!<BR><li>This is a second item! <BR><li>Now I
am
tired of this!<br></ul>";
$tpl->set_var("THISISMYCODE", $thistemp);
$tpl->parse("THISISMYCODE", false);
And in the menu label I entered:
<!--BeginTHISISMYCODE-->
{THISISMYCODE}
<!--EndTHISISMYCODE-->
My form does not load, script times out.
Thanks for the help
Frank
|
|
|
 |
Jason Charette
|
| Posted: 08/22/2001, 11:35 AM |
|
That's weird.... Worked for me.
Okay, I use CC2.0, beta 5, with PHP and Templates, connecting to Postgresql.
I have two possible reasons why this may not have worked for you:
1- The "tpl" method is case sensitive. So make sure that the
> <!--BeginTHISISMYCODE-->
> {THISISMYCODE}
> <!--EndTHISISMYCODE-->
is exactly as specified... and that the "blockname" (in my case
THISISMYCODE) is case identical as well.
Further, knowing virtually nothing of ASP, the variable assignment probably
differs, so using my example verbatim may not work...
This method is the same as that used by CC itself. Take a look at the
template file generated by the app (in my case template.php but in yours
template.asp..?) This should give you a working example of how to achieve
the same effect using ASP.
Apart from that, I can't think of why it wouldn't work.
Good luck...
J.
"Frank Rocco" <farocco@hotmail.com> wrote in message
news:9m0r7o$jpj$1@news.codecharge.com...
> I tried this and cannot get it to work.
> In the Events Before Show I entered:
> $thistemp = "<ul><li>Howdy!<BR><li>This is a second item! <BR><li>Now
I
> am
> tired of this!<br></ul>";
> $tpl->set_var("THISISMYCODE", $thistemp);
> $tpl->parse("THISISMYCODE", false);
>
> And in the menu label I entered:
> <!--BeginTHISISMYCODE-->
> {THISISMYCODE}
> <!--EndTHISISMYCODE-->
>
> My form does not load, script times out.
>
> Thanks for the help
>
> Frank
>
>
|
|
|
 |
CodeCharge
|
| Posted: 08/22/2001, 11:38 AM |
|
Hi Frank,
This code looks like PHP code. I belive you're using ASP ?
Adamm
"Frank Rocco" <farocco@hotmail.com> wrote in message
news:9m0r7o$jpj$1@news.codecharge.com...
> I tried this and cannot get it to work.
> In the Events Before Show I entered:
> $thistemp = "<ul><li>Howdy!<BR><li>This is a second item! <BR><li>Now
I
> am
> tired of this!<br></ul>";
> $tpl->set_var("THISISMYCODE", $thistemp);
> $tpl->parse("THISISMYCODE", false);
>
> And in the menu label I entered:
> <!--BeginTHISISMYCODE-->
> {THISISMYCODE}
> <!--EndTHISISMYCODE-->
>
> My form does not load, script times out.
>
> Thanks for the help
>
> Frank
>
>
|
|
|
 |
Frank Rocco
|
| Posted: 08/22/2001, 11:49 AM |
|
Ok,
I thought I could mix ASP & PHP. My main project is defined as ASP 2.0
I guess I need an ASP version as I do not yet know PHP.
Thanks
Frank
|
|
|
 |
|