Updating records with form field type "select"

Updating records with form field type "select"

am 04.04.2008 00:48:02 von Michael S

I'm retrieving records from my db and update them. Text fields are no
problem, but when it comes to different types of fields, such as 'select'
fields with options the default in the option list is the first item in the
list and not the actual database record.

For example, this text field is fine. It retrieves city and puts it into
the form:

value="<%=rs("city")%>" size="50">

But this select field is not. Although the selelct choice saves to the db,
the display in the users edit form is the first record in the select list.
I'm not sure how to make it display the record from the db.



Any help is much appreciated!!!

Re: Updating records with form field type "select"

am 04.04.2008 14:24:13 von Daniel Crichton

Michael wrote on Thu, 3 Apr 2008 15:48:02 -0700:

> I'm retrieving records from my db and update them. Text fields are no
> problem, but when it comes to different types of fields, such as
> 'select'
> fields with options the default in the option list is the first item in
> the list and not the actual database record.

> For example, this text field is fine. It retrieves city and puts it
> into the form:

> > value="<%=rs("city")%>" size="50">

> But this select field is not. Although the selelct choice saves to the
> db, the display in the users edit form is the first record in the
> select list.
> I'm not sure how to make it display the record from the db.

>

> Any help is much appreciated!!!

You need to add a "selected" attribute to the option, not set the value of
the select tag.

eg.



although this isn't very easy to code up with a long list. If your list is
db generated, then you could do something like this:

assuming rsProv is a recordset holding the provinces in a column called
"prov"



--
Dan

Re: Updating records with form field type "select"

am 04.04.2008 16:56:04 von michaels

Thanks for the assistance!

"Daniel Crichton" wrote:

> Michael wrote on Thu, 3 Apr 2008 15:48:02 -0700:
>
> > I'm retrieving records from my db and update them. Text fields are no
> > problem, but when it comes to different types of fields, such as
> > 'select'
> > fields with options the default in the option list is the first item in
> > the list and not the actual database record.
>
> > For example, this text field is fine. It retrieves city and puts it
> > into the form:
>
> > > > value="<%=rs("city")%>" size="50">
>
> > But this select field is not. Although the selelct choice saves to the
> > db, the display in the users edit form is the first record in the
> > select list.
> > I'm not sure how to make it display the record from the db.
>
> >
>
> > Any help is much appreciated!!!
>
> You need to add a "selected" attribute to the option, not set the value of
> the select tag.
>
> eg.
>
>
>
> although this isn't very easy to code up with a long list. If your list is
> db generated, then you could do something like this:
>
> assuming rsProv is a recordset holding the provinces in a column called
> "prov"
>
>
>
> --
> Dan
>
>
>