J
J. Alan Rueckgauer
I have an <input type="hidden"> on a form that has its .value set in
client-side script called from another asp in an <iframe> on that page.
When the form is posted back to the server, the field shows as being in the
form items collection, but the value is an empty string. The other <input>s
from the form seem fine.l I know the value is actually arriving in the
client because it displays both as the .innerHTML of a <td> and in
View|Source.
**********
(client page)
<script language="vbscript">
sub GotRecord(byval TheRecIdent, byval TheNameInfo, byval TheShowRecFlag)
myform.hiddenRecIdent.value = TheRecIdent
tdIdent.innerHTML = "ID: " & myform.hiddenRecIdent.value
tdNameInfo.innerHTML = TheNameInfo
if TheShowRecFlag = "1" then
myform.chkShowInfoFlag.checked = true
else
myform.chkShowInfoFlag.checked = false
end if
rowNameInfo.style.visibility = "visible"
rowEditArea.style.visibility = "visible"
end sub
....
</script>
....
<form name="myform" action="page_proc.asp" method="post"
target="ifrmPlaypen">
<input type="hidden" name="hiddenRecIdent"
value="<%=session("CurrentRecIdent")%>">
<table width="100%" id="table2">
<tr>
<td id="tdIdent"><input type="text" name="txtRecIdent"
size="20"><input type="submit" value="Get" name="B1"></td>
</tr>
<tr id="rowNameInfo" style="visibility:hidden">
<td id="tdNameInfo"> </td>
</tr>
<tr id="rowEditArea" style="visibility:hidden">
<td><input type="checkbox" name="chkShowInfoFlag" value="ON" <% if
session("CurrentRecIsVisibleFlag") = 1 then %>CHECKED<% end if %>>Include
this person in searches</td>
</tr>
</table>
<p><p align="center"><input type="submit" value="Save Changes"
name="B2"></p>
</form>
**********
(server script)
<%
... (irrelevant stuff omitted)
set TheForm = request.form
with TheForm
strPageAct = ucase(.Item("B1"))
if strPageAct = "" then
strPageAct = ucase(.Item("B2"))
end if
if instr(strPageAct, "GET") > 0 then
session("DoWhat") = "GET"
strRecIdent = Trim(.Item("txtRecIdent"))
elseif instr(strPageAct, "SAVE") > 0 then
' it knows that B2 was what caused the submit
IsPostBack = True
session("DoWhat") = "SAVE"
strRecIdent = .Item("hiddenRecIdent") '<== HERE'S WHERE THINGS
GO WRONG
' hiddenRecIdent.value never shows up
end if
end with
If strRecIdent > "" Then
Set TheAttendee = New clsAttendee
TheAttendee.GetByRegistration(strRecIdent)
With TheAttendee
If .AttendeeID = strRecIdent Then
If strPageAct = "GET" Then
session("CurrentRecIdent") = .AttendeeID
session("CurrentNameInfo") =
replace(.ContactInfoBlock(True), vbCrLf, "")
session("CurrentRecIsVisibleFlag") = .RecordStatus
ElseIf strPageAct = "SAVE" Then
' do the stuff to save the changes
End If
Else
' **** strRecIdent is always ""
session("ProcMsg") = "The AttendeeID didn't make it from the
form."
End If
%>
<html>
<head>
<SCRIPT language="VBScript">
sub Window_onload
dim huh, duh
huh = "<%=session("DoWhat")%>"
select case huh
case "GET"
window.parent.GotRecord "<%=session("CurrentRecIdent") %>",
"<%=session("CurrentNameInfo")%>", "<%=session("CurrentRecIsVisibleFlag")%>"
case "SAVE"
duh = "<%=session("ProcMsg")%>"
if duh = "" then
duh = "Record has been updated."
window.parent.RecSuccess duh
else
window.parent.RecFailed duh
end if
end select
end sub
</script>
</head>
<body>
Action: <%=strPageAct%><br>
DoWhat: <%=session("DoWhat")%><br>
Registration: <%=strRecID%></br>
Result: <%=session("ProcMsg")%><br>
<% if session("DoWhat") = "SAVE" then %>
Form Contents dump:<br>
<%
dim x
for each x in Request.Form
Response.Write("<br>" & x & " = " & Request.Form(x))
next
%>
<% end if %>
</body>
</html>
**********
So, any ideas why the hidden field's value never comes across in the POST,
even though the client sees it fine?
Thanks mucho in advance...
Alan
client-side script called from another asp in an <iframe> on that page.
When the form is posted back to the server, the field shows as being in the
form items collection, but the value is an empty string. The other <input>s
from the form seem fine.l I know the value is actually arriving in the
client because it displays both as the .innerHTML of a <td> and in
View|Source.
**********
(client page)
<script language="vbscript">
sub GotRecord(byval TheRecIdent, byval TheNameInfo, byval TheShowRecFlag)
myform.hiddenRecIdent.value = TheRecIdent
tdIdent.innerHTML = "ID: " & myform.hiddenRecIdent.value
tdNameInfo.innerHTML = TheNameInfo
if TheShowRecFlag = "1" then
myform.chkShowInfoFlag.checked = true
else
myform.chkShowInfoFlag.checked = false
end if
rowNameInfo.style.visibility = "visible"
rowEditArea.style.visibility = "visible"
end sub
....
</script>
....
<form name="myform" action="page_proc.asp" method="post"
target="ifrmPlaypen">
<input type="hidden" name="hiddenRecIdent"
value="<%=session("CurrentRecIdent")%>">
<table width="100%" id="table2">
<tr>
<td id="tdIdent"><input type="text" name="txtRecIdent"
size="20"><input type="submit" value="Get" name="B1"></td>
</tr>
<tr id="rowNameInfo" style="visibility:hidden">
<td id="tdNameInfo"> </td>
</tr>
<tr id="rowEditArea" style="visibility:hidden">
<td><input type="checkbox" name="chkShowInfoFlag" value="ON" <% if
session("CurrentRecIsVisibleFlag") = 1 then %>CHECKED<% end if %>>Include
this person in searches</td>
</tr>
</table>
<p><p align="center"><input type="submit" value="Save Changes"
name="B2"></p>
</form>
**********
(server script)
<%
... (irrelevant stuff omitted)
set TheForm = request.form
with TheForm
strPageAct = ucase(.Item("B1"))
if strPageAct = "" then
strPageAct = ucase(.Item("B2"))
end if
if instr(strPageAct, "GET") > 0 then
session("DoWhat") = "GET"
strRecIdent = Trim(.Item("txtRecIdent"))
elseif instr(strPageAct, "SAVE") > 0 then
' it knows that B2 was what caused the submit
IsPostBack = True
session("DoWhat") = "SAVE"
strRecIdent = .Item("hiddenRecIdent") '<== HERE'S WHERE THINGS
GO WRONG
' hiddenRecIdent.value never shows up
end if
end with
If strRecIdent > "" Then
Set TheAttendee = New clsAttendee
TheAttendee.GetByRegistration(strRecIdent)
With TheAttendee
If .AttendeeID = strRecIdent Then
If strPageAct = "GET" Then
session("CurrentRecIdent") = .AttendeeID
session("CurrentNameInfo") =
replace(.ContactInfoBlock(True), vbCrLf, "")
session("CurrentRecIsVisibleFlag") = .RecordStatus
ElseIf strPageAct = "SAVE" Then
' do the stuff to save the changes
End If
Else
' **** strRecIdent is always ""
session("ProcMsg") = "The AttendeeID didn't make it from the
form."
End If
%>
<html>
<head>
<SCRIPT language="VBScript">
sub Window_onload
dim huh, duh
huh = "<%=session("DoWhat")%>"
select case huh
case "GET"
window.parent.GotRecord "<%=session("CurrentRecIdent") %>",
"<%=session("CurrentNameInfo")%>", "<%=session("CurrentRecIsVisibleFlag")%>"
case "SAVE"
duh = "<%=session("ProcMsg")%>"
if duh = "" then
duh = "Record has been updated."
window.parent.RecSuccess duh
else
window.parent.RecFailed duh
end if
end select
end sub
</script>
</head>
<body>
Action: <%=strPageAct%><br>
DoWhat: <%=session("DoWhat")%><br>
Registration: <%=strRecID%></br>
Result: <%=session("ProcMsg")%><br>
<% if session("DoWhat") = "SAVE" then %>
Form Contents dump:<br>
<%
dim x
for each x in Request.Form
Response.Write("<br>" & x & " = " & Request.Form(x))
next
%>
<% end if %>
</body>
</html>
**********
So, any ideas why the hidden field's value never comes across in the POST,
even though the client sees it fine?
Thanks mucho in advance...
Alan