[ic] Problem with form select...

Todd Hight interchange-users@interchange.redhat.com
Tue Dec 18 16:15:01 2001


> -----Original Message-----
> From: interchange-users-admin@interchange.redhat.com
> [mailto:interchange-users-admin@interchange.redhat.com]On Behalf Of
> Kevin Walsh
> Sent: Tuesday, December 18, 2001 11:04 AM
> To: interchange-users@interchange.redhat.com
> Subject: Re: [ic] Problem with form select...
>
>
> > First let me say that IC rocks
> >
> Really?  I have found it to be very stable. :-)
>
As I said this list is always amusing ;-)

> >
> > and that this list is not only very informative but quite
> amusing at times :)
> >
> > I'm trying to set the default value of a select field on a from
> (using the
> > [selected] tag) to an existing value from a table.  Below is a
> quick snippet
> > of my form.  The select is always populated correctly I just
> cant seem to
> > get it to default to the current values.
> >
> > [loop prefix=slist arg="[scratch sprofile_id]"]
> >   <select name="category" size="1">
> >     [loop prefix=scat
> search="ra=yes/fi=cat/rf=code,name/ml=100/tf=name" ]
> >       <option value="[scat-data cat name]" [selected name=category
> >              value="[slist-data sprofile category]"]>
> >          [scat-data cat name]
> >       </option>
> >     [/loop]
> >   </select>
> > [/loop]
> >
> I don't really understand your use of the outer loop in this
> context.  Will there really be more than one sprofile_id value?
> I suspect not, as your <select> list has a fixed (category) variable
> name.
>

I dont really understand the outside loop either.  It was grafted from
another page and will be rewritten correctly once I understand the whole
system a little better.

> Generally, to generate an <option> list, with a default (selected)
> value, you would do something like this:
>
>     <select name="category">
>         [loop search="ra=yes/fi=cat/rf=code,name/ml=100/tf=name"
>               prefix=scat
>               option=category]
>         <option value="[scat-param name]">[scat-param name]</option>
>         [/loop]
>     </select>
>
> That will set the default (selected) option to the first one that
> matches "category" value.  I suggest you simply set the "category"
> value to a default before calling the above code, like this:
>
>     [if !value category]
>         [value name=category
>                set="[scratch sprofile_id]"
>                filter="lookup.sprofile.category"
>                hide=1]
>     [/if]
>

As always the explanation caused that dim little light in my brain to shine
a little brighter :)  Thanks!

>
> Just a suggestion: I see that you store the scat.name lookup values
> in sprofile.category.  I think it would be better to store the
> scat.code instead.  This would allow you to modify the name without
> breaking things in the future, and would also save having to do that
> filter lookup in the [value] tag.
>

I would agree. In a production environment I would always store the code not
the name.  I have been learning and this is really just a proof of concept
page that I'm working on.

Thanks again for the valuable insight!

> --
>    _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
>   _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
>  _/ _/    _/          _/ _/     _/    _/  _/_/    kevin@cursor.uk.com
> _/   _/  _/_/_/_/      _/    _/_/_/  _/    _/
>
> _______________________________________________
> interchange-users mailing list
> interchange-users@interchange.redhat.com
> http://interchange.redhat.com/mailman/listinfo/interchange-users