Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request.Form lost elements

Status
Not open for further replies.

ashaig

Programmer
Apr 9, 2001
26
GB
Hi,

I'm using a function I've used successfully before with dropdown listboxes, but its not working with checkboxes. Basically, if the "breakfast" box is NOT checked (from screen or database) the element does NOT get picked up when I use Request.Form in the function btnSave_onclick. Code is below for some kind person. I hope the Visual Interdev Designtime Control code isn't too much of a distraction! (I don't think it affects this problem)


<%@ Language=JavaScript %>
<% // VI 6.0 Scripting Object Model Enabled %>
<!--#include file=&quot;_ScriptLibrary/pm.asp&quot;-->
<% if (StartPageProcessing()) Response.End() %>
<FORM name=thisForm METHOD=post>
<html>
<head>
<meta NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<LINK rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;Style1.css&quot;>

<SCRIPT ID=serverEventHandlersJS LANGUAGE=javascript RUNAT=Server>

function btnSave_onclick() {


if (Request.Form.Count > 0)
{
var tempRS = loRS.getRecordSource();
var num = 0;

for (var i = 1; i <= Request.Form(&quot;abspos&quot;).Count;i = i + 1)
{
num = Request.Form(&quot;abspos&quot;)(i);

tempRS.absolutePosition = parseInt(num, 10);

if (Request.Form(&quot;breakfast&quot;)(i) == &quot;true&quot;)
{
tempRS(&quot;breakfast&quot;) = &quot;true&quot;;
}
else
{
tempRS(&quot;breakfast&quot;) = &quot;false&quot;;
}

}
tempRS.update;

loRS.setRecordSource(tempRS);
Response.Write(&quot;<P class=two>&quot;);
Response.Write(&quot;Save Successful&quot;);
Response.Write(&quot;</P>&quot;);
}
}



</SCRIPT>
<% var backcolor = &quot;white&quot;; %>
</head>

<body bgcolor=&quot;<%=backcolor%>&quot;>
<%


var pTempCookie = unescape(Request.QueryString);
var TempData = pTempCookie.split(&quot;&&quot;);
var spersonid = parseInt(TempData[0], 10);
var sfirst = TempData[1];
var ssur = TempData[2];
var sError = TempData[3];
var visitid = Request.Cookies(&quot;visit&quot;);
var z = 1;
Response.Cookies(&quot;fname&quot;) = sfirst;
Response.Cookies(&quot;sname&quot;) = ssur;
Response.Cookies(&quot;person&quot;) = spersonid;
loRS.close();
loRS.setParameter(1, spersonid);
loRS.open();

%>
<!--METADATA TYPE=&quot;DesignerControl&quot; startspan
<OBJECT classid=&quot;clsid:9CF5D7C2-EC10-11D0-9862-0000F8027CA0&quot; id=loRS style=&quot;LEFT: 0px; TOP: 0px&quot;>
<PARAM NAME=&quot;ExtentX&quot; VALUE=&quot;12197&quot;>
<PARAM NAME=&quot;ExtentY&quot; VALUE=&quot;2090&quot;>
<PARAM NAME=&quot;State&quot; VALUE=&quot;(TCConn=\qraasayConn\q,TCDBObject=\qStored\sProcedures\q,TCDBObjectName=\qIndPlanner\s(dbo)\q,TCControlID_Unmatched=\qloRS\q,TCPPConn=\qraasayConn\q,RCDBObject=\qRCDBObject\q,TCPPDBObject=\qStored\sProcedures\q,TCPPDBObjectName=\qIndPlanner\s(dbo)\q,TCCursorType=\q3\s-\sStatic\q,TCCursorLocation=\q3\s-\sUse\sclient-side\scursors\q,TCLockType=\q3\s-\sOptimistic\q,TCCacheSize_Unmatched=\q30\q,TCCommTimeout_Unmatched=\q10\q,CCPrepared=0,CCAllRecords=1,TCNRecords_Unmatched=\q10\q,TCODBCSyntax_Unmatched=\q\q,TCHTargetPlatform=\q\q,TCHTargetBrowser_Unmatched=\qServer\s(ASP)\q,TCTargetPlatform=\qInherit\sfrom\spage\q,RCCache=\qRCBookPage\q,CCOpen=0,GCParameters=(Rows=1,Row1=(CType_Unmatched=\qIn\q,CParName_Unmatched=\q@personid\q,CDataType_Unmatched=\qInteger\q,CSize_Unmatched=\q0\q,CReq=0)))&quot;></OBJECT>
-->
<!--#INCLUDE FILE=&quot;_ScriptLibrary/Recordset.ASP&quot;-->
<SCRIPT LANGUAGE=&quot;JavaScript&quot; RUNAT=&quot;server&quot;>
function _setParametersloRS()
{
}
function _initloRS()
{
loRS.advise(RS_ONBEFOREOPEN, _setParametersloRS);
var DBConn = Server.CreateObject('ADODB.Connection');
DBConn.ConnectionTimeout = Application('raasayConn_ConnectionTimeout');
DBConn.CommandTimeout = Application('raasayConn_CommandTimeout');
DBConn.CursorLocation = Application('raasayConn_CursorLocation');
DBConn.Open(Application('raasayConn_ConnectionString'), Application('raasayConn_RuntimeUserName'), Application('raasayConn_RuntimePassword'));
var cmdTmp = Server.CreateObject('ADODB.Command');
var rsTmp = Server.CreateObject('ADODB.Recordset');
cmdTmp.ActiveConnection = DBConn;
rsTmp.Source = cmdTmp;
cmdTmp.CommandType = 4;
cmdTmp.CommandTimeout = 10;
cmdTmp.CommandText = '&quot;IndPlanner&quot;';
rsTmp.CacheSize = 30;
rsTmp.CursorType = 3;
rsTmp.CursorLocation = 3;
rsTmp.LockType = 3;
loRS.setRecordSource(rsTmp);
if (thisPage.getState('pb_loRS') != null)
loRS.setBookmark(thisPage.getState('pb_loRS'));
}
function _loRS_ctor()
{
CreateRecordset('loRS', _initloRS, null);
}
function _loRS_dtor()
{
loRS._preserveState();
thisPage.setState('pb_loRS', loRS.getBookmark());
}
</SCRIPT>

<!--METADATA TYPE=&quot;DesignerControl&quot; endspan-->
<TABLE>
<TR>
<TD width=200></TD>
<TD width=400 class=&quot;four&quot;>Individual Planner - <%=sfirst%>  <%=ssur%>
</TD>
</TR>
<TR>
<TD><a class=&quot;two&quot; href=&quot;Javascript:window.close()&quot;>Close Window</a>
</TD>
<TD class=&quot;two&quot;><%=sError%></TD>
<TD width=400></TD>
<TD>
<!--METADATA TYPE=&quot;DesignerControl&quot; startspan
<OBJECT classid=&quot;clsid:B6FC3A14-F837-11D0-9CC8-006008058731&quot; height=27 id=btnSave style=&quot;HEIGHT: 27px; LEFT: 0px; TOP: 0px; WIDTH: 52px&quot;
width=52>
<PARAM NAME=&quot;_ExtentX&quot; VALUE=&quot;1376&quot;>
<PARAM NAME=&quot;_ExtentY&quot; VALUE=&quot;714&quot;>
<PARAM NAME=&quot;id&quot; VALUE=&quot;btnSave&quot;>
<PARAM NAME=&quot;Caption&quot; VALUE=&quot;Save&quot;>
<PARAM NAME=&quot;Image&quot; VALUE=&quot;&quot;>
<PARAM NAME=&quot;AltText&quot; VALUE=&quot;&quot;>
<PARAM NAME=&quot;Visible&quot; VALUE=&quot;-1&quot;>
<PARAM NAME=&quot;Platform&quot; VALUE=&quot;256&quot;>
<PARAM NAME=&quot;LocalPath&quot; VALUE=&quot;&quot;></OBJECT>
-->
<!--#INCLUDE FILE=&quot;_ScriptLibrary/Button.ASP&quot;-->
<SCRIPT LANGUAGE=JavaScript RUNAT= Server>
function _initbtnSave()
{
btnSave.value = 'Save';
btnSave.setStyle(0);
}
function _btnSave_ctor()
{
CreateButton('btnSave', _initbtnSave, null);
}
</script>
<% btnSave.display(); %>

<!--METADATA TYPE=&quot;DesignerControl&quot; endspan-->
</TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD></TD><TD class=&quot;one&quot;>Date</TD>
<TD class=&quot;one&quot;>Breakfast   </TD>
</TR>
<%
if (!loRS.EOF)

{
while (!(loRS.EOF))
{
%>
<TR>
<TD><INPUT TYPE=&quot;HIDDEN&quot; NAME=&quot;abspos&quot; VALUE=<%=loRS.absolutePosition%>>
</TD>
<TD>
<%=loRS.fields.getValue(&quot;visitdate&quot;)%>
</TD>
<TD>
<input type=&quot;checkbox&quot; name=&quot;breakfast&quot; value=&quot;<%=loRS.fields.getValue(&quot;breakfast&quot;)%>&quot;
<% if (loRS.fields.getValue(&quot;breakfast&quot;) == &quot;true&quot;){%> CHECKED <% } %> >
</TD>
</TR>
<%
z++;
loRS.moveNext();
}
}
else
{
%>
<P class=&quot;one&quot;> Please Initialise IND_DAILY_PLAN</P><br>
<%
}
%>

<TR>
<TD width=200><a class=&quot;two&quot; href=&quot;Javascript:window.close()&quot;>Close Window</a>
</TD>

</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD>
<TD>
<!--METADATA TYPE=&quot;DesignerControl&quot; startspan
<OBJECT classid=&quot;clsid:B6FC3A14-F837-11D0-9CC8-006008058731&quot; height=27 id=btnSave style=&quot;HEIGHT: 27px; LEFT: 0px; TOP: 0px; WIDTH: 52px&quot;
width=52>
<PARAM NAME=&quot;_ExtentX&quot; VALUE=&quot;1376&quot;>
<PARAM NAME=&quot;_ExtentY&quot; VALUE=&quot;714&quot;>
<PARAM NAME=&quot;id&quot; VALUE=&quot;btnSave&quot;>
<PARAM NAME=&quot;Caption&quot; VALUE=&quot;Save&quot;>
<PARAM NAME=&quot;Image&quot; VALUE=&quot;&quot;>
<PARAM NAME=&quot;AltText&quot; VALUE=&quot;&quot;>
<PARAM NAME=&quot;Visible&quot; VALUE=&quot;-1&quot;>
<PARAM NAME=&quot;Platform&quot; VALUE=&quot;256&quot;>
<PARAM NAME=&quot;LocalPath&quot; VALUE=&quot;&quot;></OBJECT>
-->
<SCRIPT LANGUAGE=JavaScript RUNAT= Server>
function _initbtnSave()
{
btnSave.value = 'Save';
btnSave.setStyle(0);
}
function _btnSave_ctor()
{
CreateButton('btnSave', _initbtnSave, null);
}
</script>
<% btnSave.display(); %>

<!--METADATA TYPE=&quot;DesignerControl&quot; endspan-->
</TD>
</TR>
</TABLE>


<P>
<!--METADATA TYPE=&quot;DesignerControl&quot; startspan
<OBJECT classid=&quot;clsid:CEB04D01-0445-11D1-BB81-006097C553C8&quot; id=VisitManager style=&quot;LEFT: 0px; TOP: 0px&quot;>
<PARAM NAME=&quot;ExtentX&quot; VALUE=&quot;4233&quot;>
<PARAM NAME=&quot;ExtentY&quot; VALUE=&quot;609&quot;>
<PARAM NAME=&quot;State&quot; VALUE=&quot;(txtName_Unmatched=\qVisitManager\q,txtNewMode_Unmatched=\q\q,grFormMode=(Rows=2,Row1=(txtMode_Unmatched=\qDisplay\q),Row2=(txtMode_Unmatched=\qUpdated\q)),txtDefaultMode=\qDisplay\q,grMasterMode=(Rows=5,Row1=(txtName_Unmatched=\q1\q,txtControl_Unmatched=\qbtnSave\q,txtProperty_Unmatched=\qshow\q,txtValue_Unmatched=\q()\q),Row2=(txtName_Unmatched=\q1\q,txtControl_Unmatched=\qbtnSave\q,txtProperty_Unmatched=\qdisabled\q,txtValue_Unmatched=\qfalse\q),Row3=(txtName_Unmatched=\q1\q,txtControl_Unmatched=\qbtnFill\q,txtProperty_Unmatched=\qhide\q,txtValue_Unmatched=\q()\q),Row4=(txtName_Unmatched=\q2\q,txtControl_Unmatched=\qbtnFill\q,txtProperty_Unmatched=\qshow\q,txtValue_Unmatched=\q()\q),Row5=(txtName_Unmatched=\q2\q,txtControl_Unmatched=\qbtnFill\q,txtProperty_Unmatched=\qdisabled\q,txtValue_Unmatched=\qfalse\q)),grTransitions=(Rows=4,Row1=(txtCurrentMode=\qDisplay\q,txtObject=\qbtnSave\q,txtEvent=\qonclick\q,txtNextMode=\qUpdated\q),Row2=(txtCurrentMode=\qUpdated\q,txtObject=\qbtnSave\q,txtEvent=\qonclick\q,txtNextMode=\qUpdated\q),Row3=(txtCurrentMode=\qDisplay\q,txtObject=\qbtnFill\q,txtEvent=\qonclick\q,txtNextMode=\qUpdated\q),Row4=(txtCurrentMode=\qUpdated\q,txtObject=\qbtnFill\q,txtEvent=\qonclick\q,txtNextMode=\qUpdated\q)),grMasterStep=(Rows=4,Row1=(txtName_Unmatched=\q1\q),Row2=(txtName_Unmatched=\q2\q),Row3=(txtName_Unmatched=\q3\q),Row4=(txtName_Unmatched=\q4\q)))&quot;></OBJECT>
-->
<SCRIPT RUNAT=SERVER LANGUAGE=&quot;JavaScript&quot;>
function _VisitManager_ctor()
{
thisPage.advise(PAGE_ONINIT, _VisitManager_init);
}
function _VisitManager_init()
{
if (thisPage.getState(&quot;VisitManager_formmode&quot;) == null)
_VisitManager_SetMode(&quot;Display&quot;);
btnSave.advise(&quot;onclick&quot;, &quot;_VisitManager_btnSave_onclick()&quot;);
btnFill.advise(&quot;onclick&quot;, &quot;_VisitManager_btnFill_onclick()&quot;);
}
function _VisitManager_SetMode(formmode)
{
thisPage.setState(&quot;VisitManager_formmode&quot;, formmode);
if (formmode == &quot;Display&quot;)
{
btnSave.show();
btnSave.disabled = false;
btnFill.hide();
}
if (formmode == &quot;Updated&quot;)
{
btnFill.show();
btnFill.disabled = false;
}
}
function _VisitManager_btnSave_onclick()
{
if (thisPage.getState(&quot;VisitManager_formmode&quot;) == &quot;Display&quot;)
{
_VisitManager_SetMode(&quot;Updated&quot;);
}
else if (thisPage.getState(&quot;VisitManager_formmode&quot;) == &quot;Updated&quot;)
{
_VisitManager_SetMode(&quot;Updated&quot;);
}
else _VisitManager_SetMode(thisPage.getState(&quot;VisitManager_formmode&quot;))
}
function _VisitManager_btnFill_onclick()
{
if (thisPage.getState(&quot;VisitManager_formmode&quot;) == &quot;Display&quot;)
{
_VisitManager_SetMode(&quot;Updated&quot;);
}
else if (thisPage.getState(&quot;VisitManager_formmode&quot;) == &quot;Updated&quot;)
{
_VisitManager_SetMode(&quot;Updated&quot;);
}
else _VisitManager_SetMode(thisPage.getState(&quot;VisitManager_formmode&quot;))
}
</SCRIPT>


<!--METADATA TYPE=&quot;DesignerControl&quot; endspan-->
</P>

</body>
<% // VI 6.0 Scripting Object Model Enabled %>
<% EndPageProcessing() %>
</FORM>
</html>

 
I didn't read through the whole thing....this is too much to post until it comes to a later time that it is determined it is needed. Please only post what is necessary.


If I understand your problem right, you are trying to mix server-side and client-side code to accomplish the same task. Problem is, you can't have the sever-side code know when the button is pushed(clicked) because it's on the client side. (isn't like VB programming). So, you need tohave the form submit the page (even if it's to itself) and then you can use the request.form on the server-side pick up the information and you can do with it as you like.

let me know if I read into your problem incorrectly. -Ovatvvon :-Q
 
Hi,

I'm using FormManager in Visual Interdev, which seems to handle using one page effectively. As I said this function works great with dropdown listboxes already - so the overall functionality isn't at fault.
Could it be that HTML doesn't add an element to Forms Collection if it is empty?

Thanks for your prompt reply.
 
oh, ok, I think I know what you're saying now...

If I understand right then, when you have the checkbox checked, and you submit to the page, it shows an &quot;on&quot;, &quot;1&quot;, or &quot;true&quot;. However, if it is not checked, you get nothing...is that correct?

What you have to do is check if there is a value you know it will show. For instance, if you are using an access database, they like to return &quot;on&quot; a lot.


If Request.Form(&quot;breakfast&quot;) = &quot;on&quot; Then
Response.write(&quot;The person wants breakfast in the morning&quot;)
Else
Response.write(&quot;The person does not want breakfast&quot;)
End If


Does this help?
-Ovatvvon :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top