[ic] Problem with form select...

Todd Hight interchange-users@interchange.redhat.com
Thu Dec 20 16:58:01 2001


> -----Original Message-----
> From: interchange-users-admin@interchange.redhat.com
> [mailto:interchange-users-admin@interchange.redhat.com]On Behalf Of Mike
> Heins
> Sent: Thursday, December 20, 2001 1:41 PM
> To: interchange-users@interchange.redhat.com
> Subject: Re: [ic] Problem with form select...
>
>
> Quoting Todd Hight (thight@twol8.net):
> >
> > First let me say that IC rocks 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.
> >
> > All other from fields, mostly text boxes, work fine.  Even the
> field below
> > will save the  selected value properly.  In fact, once you complete the
> > from, the next time you call the page that contains the
> snippet, you get the
> > last value selected.
> >
> > Current config is IC 4.8.3, Apache 1.3.22, Perl 5.6.1,
> PostgreSQL 7.1.3 all
> > running on RedHat Linux 7.1 with kernel 2.4.9 SMP.
> >
> > I'm quite new to IC, just a couple of weeks now. So please be
> kind :) I'm
> > sure there is a simple solution!
> >
> > I hope this all made sense...
> >
> > TIA
> >
> > <>< Todd
> >
> > -----------------------------------------------------
> >
> > [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]
>
> This is because the [selected ...] tag relies on what is in
> [value category]
> to determine whether the option is selected. Before there is a
> value there,
> you will not get anything selected by default.
>
> You would need to set $Values->{category} to something to get that done,
> or if you are passing it via a CGI variable you need to do
>
>     [selected cgi=1 name=category value="[slist-data sprofile category]"]
>
> That being said, you would be much better off doing:
>
>   [loop
> 	prefix=scat
> 	search="
> 		ra=yes
> 		fi=cat
> 		rf=code,name
> 		ml=100
> 		tf=name
> 	"
> 	option=category
> 	cgi=1
>   ]
>
> The combination of option=category and cgi=1 is the same as the
> [selected cgi=1 name=category ...] tag and is much more efficient.
>

Thanks.... It makes perfect sense now :)  Make my code/html look much nicer
too!

> --
> Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
> phone +1.513.523.7621      <mheins@redhat.com>
>
> Happy Holidays! ** (See Footnote 1)
>
> ** Footnote 1:
>
> Please accept with no obligation, implied or implicit, our best wishes
> for an environmentally conscious, socially responsible, low stress,
> non-addictive, gender neutral, celebration of the winter solstice
> holiday, practised within the most enjoyable traditions of the religious
> persuasion of your choice, or secular practices of your choice, with
> respect for the religious/secular persuasions and/or traditions of
> others, or their choice not to practice religious or secular traditions
> at all . . . and a fiscally successful, personally fulfilling, and
> medically uncomplicated recognition of the onset of the generally
> accepted calendar year 2001, but not without due respect for the
> calendars of choice of other cultures whose contributions to society
> have helped make America great, (not to imply that America is
> necessarily greater than any other country or is the only "AMERICA" in
> the western hemisphere), and without regard to the race, creed, colour,
> age, physical ability, religious faith, choice of computer platform, or
> sexual preference of the wishee.
>
> By accepting this greeting, you are accepting these terms. This greeting
> is subject to clarification or withdrawal. It is freely transferable
> with no alteration to the original greeting. It implies no promise by
> the wisher to actually implement any of the wishes for her/himself or
> others, and is void where prohibited by law, and is revocable at the
> sole discretion of the wisher. This wish is warranted to perform as
> expected within the usual application of good tidings for a period of
> one year, or until the issuance of a subsequent holiday greeting,
> whichever comes first, and warranty is limited to replacement of this
> wish or issuance of a new wish at the sole discretion of the wisher.
>
> The wishee further agrees to hold harmless and indemnify the wisher,
> along with its heirs, assigns, officers, directors, shareholders . . .
> _______________________________________________
> interchange-users mailing list
> interchange-users@interchange.redhat.com
> http://interchange.redhat.com/mailman/listinfo/interchange-users