Request Form not showing hidden field value

L

L

Hello,

I am looping through a recordset and would like the value of the
strvarcb(checkbox) and strvarhv(hidden field) to be the names of the input
fields respectively:

I would like the results to be:
CB_020
CB_021, etc...

What's wrong with the Response.Write <INPUT....> statement?
See Code Below:

Do While Not objRS.EOF
strvarid = objRS("CompanyID")
strvarcb = "CB_" & strvarid
strvarhv = "HV_" & strvarid

If objRS("SendMsg") = True then
active = "YES"
chkd = "CHECKED"
Else
active = "NO"
chkd="NOTCHECKED"

End if
'
'
Response.Write "<INPUT Type ='Checkbox' Name='" &strvarcb& "' Value='Yes' "
&chkd& " >"
Response.Write "<INPUT Type='Hidden' Name='"&strvarhv&"' Value = '"
&active& "'>"
'
For Each item in Request.Form()
Response.Write(item &"<p>")
Next

se.Write(item &"<p>")
Next

Results:

fpdbr_0_PagingMove
ContactState1
txtUserEmail
Search

I would like the results to be:
CB_020
CB_021, etc...

What's wrong with the Response.Write <INPUT....> statement?
 
S

Stefan B Rusynko

1) your snippet has a Do While w/o a Loop statement closing it, and no recordset movement (.MoveNext )
- presuming it was just not shown by you but is there somewhere - I added them in 5 below)

2) there is no such attribute as chkd="NOTCHECKED" for a checkbox field in html
Change your If statement to write an empty value for chkd which will display/write nothing
If objRS("SendMsg") = True then
active = "YES"
chkd = "CHECKED"
Else
active = "NO"
chkd = ""

3) is objRS("CompanyID") a text field or nontext (numeric) field in the DB structure
- is it is not text you need to convert it's numeric value to a string before concatenation using
strvarid = Cstr(objRS("CompanyID"))

4) why are you not also passing "active" (for the Value='Yes' ") in:
Response.Write "<INPUT Type ='Checkbox' Name='" &strvarcb& "' Value='Yes' " & chkd & " >"
If the box is checked (chkd = "CHECKED") or not checked, normally the field value should also change

5) your snippet has bad For loops (one w/ a Next missing a For) per your below snippet (delete the 4th & 5th lines as errors and add
your recordset looping):

For Each item in Request.Form()
Response.Write(item &"<p>")
Next
' se.Write(item &"<p>") 'delete
' Next 'delete
objRS.MoveNext ' added
Loop 'added

- also trust you are aware that this "for loop" only returns the form field names for "item".
To also get the field values use:

For each Item in Request.Form()
response.write "<p>" & Item & " - "
response.write Request.Form(Item).Item
response.write "</p>"
Next

6) from your Results starting w/ "fpdbr_0_PagingMove", your 1st form field name coming from the For Each item in Request.Form(),
looks like your Do While Loop is not finding any records (or looping) so it is not processing your response.writes (see 1 above)
- test it by adding after your: strvarhv = "HV_" & strvarid
Response.Write strvarid & " - " & strvarcb & " - " & strvarhv & "<br>"
Or verify you are not at EOF by adding before your Do Loop

If (objRS.EOF) Then
Response.write "No records found"
End If




| Hello,
|
| I am looping through a recordset and would like the value of the
| strvarcb(checkbox) and strvarhv(hidden field) to be the names of the input
| fields respectively:
|
| I would like the results to be:
| CB_020
| CB_021, etc...
|
| What's wrong with the Response.Write <INPUT....> statement?
| See Code Below:
|
| Do While Not objRS.EOF
| strvarid = objRS("CompanyID")
| strvarcb = "CB_" & strvarid
| strvarhv = "HV_" & strvarid
|
| If objRS("SendMsg") = True then
| active = "YES"
| chkd = "CHECKED"
| Else
| active = "NO"
| chkd="NOTCHECKED"
|
| End if
| '
| '
| Response.Write "<INPUT Type ='Checkbox' Name='" &strvarcb& "' Value='Yes' "
| &chkd& " >"
| Response.Write "<INPUT Type='Hidden' Name='"&strvarhv&"' Value = '"
| &active& "'>"
| '
| For Each item in Request.Form()
| Response.Write(item &"<p>")
| Next
|
| se.Write(item &"<p>")
| Next
|
| Results:
|
| fpdbr_0_PagingMove
| ContactState1
| txtUserEmail
| Search
|
| I would like the results to be:
| CB_020
| CB_021, etc...
|
| What's wrong with the Response.Write <INPUT....> statement?
 
L

L

Thanks Stefan for all your help.

Stefan B Rusynko said:
1) your snippet has a Do While w/o a Loop statement closing it, and no recordset movement (.MoveNext )
- presuming it was just not shown by you but is there somewhere - I added them in 5 below)

2) there is no such attribute as chkd="NOTCHECKED" for a checkbox field in html
Change your If statement to write an empty value for chkd which will display/write nothing
If objRS("SendMsg") = True then
active = "YES"
chkd = "CHECKED"
Else
active = "NO"
chkd = ""

3) is objRS("CompanyID") a text field or nontext (numeric) field in the DB structure
- is it is not text you need to convert it's numeric value to a string before concatenation using
strvarid = Cstr(objRS("CompanyID"))

4) why are you not also passing "active" (for the Value='Yes' ") in:
Response.Write "<INPUT Type ='Checkbox' Name='" &strvarcb& "' Value='Yes' " & chkd & " >"
If the box is checked (chkd = "CHECKED") or not checked, normally the field value should also change

5) your snippet has bad For loops (one w/ a Next missing a For) per your below snippet (delete the 4th & 5th lines as errors and add
your recordset looping):

For Each item in Request.Form()
Response.Write(item &"<p>")
Next
' se.Write(item &"<p>") 'delete
' Next 'delete
objRS.MoveNext ' added
Loop 'added

- also trust you are aware that this "for loop" only returns the form field names for "item".
To also get the field values use:

For each Item in Request.Form()
response.write "<p>" & Item & " - "
response.write Request.Form(Item).Item
response.write "</p>"
Next

6) from your Results starting w/ "fpdbr_0_PagingMove", your 1st form field name coming from the For Each item in Request.Form(),
looks like your Do While Loop is not finding any records (or looping) so it is not processing your response.writes (see 1 above)
- test it by adding after your: strvarhv = "HV_" & strvarid
Response.Write strvarid & " - " & strvarcb & " - " & strvarhv & "<br>"
Or verify you are not at EOF by adding before your Do Loop

If (objRS.EOF) Then
Response.write "No records found"
End If




| Hello,
|
| I am looping through a recordset and would like the value of the
| strvarcb(checkbox) and strvarhv(hidden field) to be the names of the input
| fields respectively:
|
| I would like the results to be:
| CB_020
| CB_021, etc...
|
| What's wrong with the Response.Write <INPUT....> statement?
| See Code Below:
|
| Do While Not objRS.EOF
| strvarid = objRS("CompanyID")
| strvarcb = "CB_" & strvarid
| strvarhv = "HV_" & strvarid
|
| If objRS("SendMsg") = True then
| active = "YES"
| chkd = "CHECKED"
| Else
| active = "NO"
| chkd="NOTCHECKED"
|
| End if
| '
| '
| Response.Write "<INPUT Type ='Checkbox' Name='" &strvarcb& "' Value='Yes' "
| &chkd& " >"
| Response.Write "<INPUT Type='Hidden' Name='"&strvarhv&"' Value = '"
| &active& "'>"
| '
| For Each item in Request.Form()
| Response.Write(item &"<p>")
| Next
|
| se.Write(item &"<p>")
| Next
|
| Results:
|
| fpdbr_0_PagingMove
| ContactState1
| txtUserEmail
| Search
|
| I would like the results to be:
| CB_020
| CB_021, etc...
|
| What's wrong with the Response.Write <INPUT....> statement?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top