Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ASP Web Form Database Pull Help

0 views
Skip to first unread message

Jason

unread,
Sep 8, 2008, 12:57:05 PM9/8/08
to
So I have an online submission form that submits info to a Access
database. I also have a second page where the user can update their
info on the form (which pulls the data from the database of course).
The text fields pull fine, but I'm having problems pulling data of
Dropdowns, Checkboxes, and Radio Buttons. For instance, if someone had
selected a checkbox from the submission form, when they go to the
"update" form, the checkbox would be checked.

Any help is much appreciated.

Phil Grimpo

unread,
Sep 8, 2008, 5:06:39 PM9/8/08
to Jason
You'd use if>then statements in your dropdown or checkbox or radio button.

<%IF rs_data("Option") = x then Response.Write("Selected")%>

You'll have to put that on every option possibility.

-g

Mike Brind [MVP]

unread,
Sep 9, 2008, 3:20:56 AM9/9/08
to
If you are populating the Select element from a recordset, here's a more
elegant way:

Sub doDropDownMatch(sql,sSelect,iMatch,oConn)
Dim rsDDL, arrDDL, dloop
Set rsDDL = oConn.execute(sql)
Response.Write "<select name=""" & sSelect & """>" & vbcrlf
Response.Write "<option></option>" & vbcrlf
If Not rsDDL.EOF Then
arrDDL = rsDDL.Getrows()
rsDDL.Close : Set rsDDL = Nothing
For dloop = 0 to Ubound(arrDDL,2)
Response.Write "<option value=""" & arrDDL(0,dloop) & """"
If IsNumeric(iMatch) Then
If Clng(arrDDL(0,dLoop)) = Clng(iMatch) Then Response.Write "
selected=""selected"""
End If
Response.Write ">" & arrDDL(1,dloop) & "</option>" & vbcrlf
Next
Else
rsDDL.Close : Set rsDDL = Nothing
End If
Response.Write "</select>"
End Sub

You'd just pass in the following arguments: the SQL that needs to be
executed, the html name attribute you want to give the Select element, the
(integer) value you want to match, and an open connection object.

--
Mike Brind
MVP - ASP/ASP.NET

"Phil Grimpo" <pgr...@inspirmedia.com> wrote in message
news:48C593DF...@inspirmedia.com...

Jason

unread,
Sep 10, 2008, 9:27:42 AM9/10/08
to
> "Phil Grimpo" <pgri...@inspirmedia.com> wrote in message

>
> news:48C593DF...@inspirmedia.com...
>
>
>
> > You'd use if>then statements in your dropdown or checkbox or radio button.
>
> > <%IF rs_data("Option") = x then Response.Write("Selected")%>
>
> > You'll have to put that on every option possibility.
>
> > -g
>
> > Jason wrote:
> >> So I have an online submission form that submits info to a Access
> >> database. I also have a second page where the user can update their
> >> info on the form (which pulls the data from the database of course).
> >> The text fields pull fine, but I'm having problems pulling data of
> >> Dropdowns, Checkboxes, and Radio Buttons. For instance, if someone had
> >> selected a checkbox from the submission form, when they go to the
> >> "update" form, the checkbox would be checked.
>
> >> Any help is much appreciated.- Hide quoted text -
>
> - Show quoted text -

Here's the original code:

<input name="Child_YCSDPreviousEnrolled"
id="Child_YCSDPreviousEnrolled" type="radio" value="Yes" />Yes
&nbsp;&nbsp;
<input name="Child_YCSDPreviousEnrolled"
id="Child_YCSDPreviousEnrolled" type="radio" value="No" />No

///////////////////////////////////////

So it would be changed to this:

<input name="Child_YCSDPreviousEnrolled"
id="Child_YCSDPreviousEnrolled" type="radio" value="<%IF
rs_Student("Option") = Yes then Response.Write("Selected")%>" />Yes
&nbsp;&nbsp;
<input name="Child_YCSDPreviousEnrolled"
id="Child_YCSDPreviousEnrolled" type="radio" value="<%IF
rs_Student("Option") = No then Response.Write("Selected")%>" />No

0 new messages