...

View Full Version : having trouble grasping: field.Children(1).SetFieldValue field.Children(1)...



harbingerOTV
01-25-2007, 03:57 AM
OKay here's th enew situation. I have a large html form that submits to a access db. The backend sends an email to the owner and they log in and retrieve the info. What it does it loads a copy of the same form and populates the feilds with the info from the db. what I'm having problems with are the radio buttons writing properly.

here's a sample of the first form:


<td class="nb">
<input type="radio" value="yes" name="r2">
<input type="radio" value="no" name="r2">
</td>


here's the back end getting that info and writing to the db:


rs("R2") = request.form("r2")


all that works just fine.

here's where the "populated" form pulls the info from the db.


<td class="nb">
<%=pRS("R2")%>
</td>


that sort of works. I mean it works fine for the text inputs, but the radios are inputting 0 and 1 and thus rewriting out 0 and 1

here's the part that I don't really understand, maybe because, yet again, it's my first time dealing with all this and trying to make a workable model for the future. The original code wrote to a pdf but I'm trying to make it rewrite to an html form.



<% for i = 1 to 33 %>
<%
fieldname = "R" & i
Response.Write(fieldname)
Set Field = Doc.Form.FindField(fieldname)
if i <> 31 or i <> 32 or i <> 33 or i <> 1 then
if rs(fieldname) = "Yes" then
Response.Write(rs(fieldname))
field.Children(2).SetFieldValue "Off", Nothing
field.Children(1).SetFieldValue field.Children(1).FieldOnValue, Nothing
elseif rs(fieldname) = "No" then
Response.Write(rs(fieldname))
field.Children(1).SetFieldValue "Off", Nothing
field.Children(2).SetFieldValue field.Children(2).FieldOnValue, Nothing
end if


Im sending different rules for 1, 31, 32 and 33 so this is the part that controls the yes/no radios.

so let me see if I get this at all.


<% for i = 1 to 33 %>

says i is equal to 1 - 33


fieldname = "R" & i

sets the varibale that fieldname is i +1 (through 33)


Response.Write(fieldname)
Set Field = Doc.Form.FindField(fieldname)
if i <> 31 or i <> 32 or i <> 33 or i <> 1 then

writes the feildname (r1, r2, etc)
not really sure
ignores those 4 fieldnames


if rs(fieldname) = "Yes" then
Response.Write(rs(fieldname))
field.Children(2).SetFieldValue "Off", Nothing
field.Children(1).SetFieldValue field.Children(1).FieldOnValue, Nothing
elseif rs(fieldname) = "No" then
Response.Write(rs(fieldname))
field.Children(1).SetFieldValue "Off", Nothing
field.Children(2).SetFieldValue field.Children(2).FieldOnValue, Nothing


okay here's where Im surely confused.
couldn't I just do something like (since i'm not actually checking radios on the repopulated form but rather writing yes/no in thier place:


<% for i = 1 to 33 %>
<%
fieldname = "R" & i
Response.Write(fieldname)
Set Field = Doc.Form.FindField(fieldname)
if i <> 31 or i <> 32 or i <> 33 or i <> 1 then
if rs(fieldname) = field.Children(1) then
Response.Write(Yes)
elseif rs(fieldname) = field.Children(2) then
Response.Write(No)
end if



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum