I have an asp page that has a form to collect user data in a form.
when the user clicks submit the input is validated. If any fields are
not acceptable the user clicks on a button to go back to the original
form to correct the input. This all works fine until I try to
incorporate a javascript to display a popup calendar which posts the
selected date back to a field on the form. This script works fine in
itself, however if the page is submitted after this script has run and
other fields are not valid, then when I go back to the form ALL the
data entered is cleared. I am fairly new to asp and at a lost as to
what i am doing wrong.
I would appreciate any pointers as to how I can correct this.
My asp page is is follows:
Handles database connects
' contains the Javascript to
handle the popup window
<% If (0 = Request.ServerVariables("CONTENT_LENGTH")) Then %>
Re: Problem when using javascript
am 09.12.2006 23:27:31 von Mike Brind
wrote in message
news:1165699095.201469.142280@j44g2000cwa.googlegroups.com.. .
>I have an asp page that has a form to collect user data in a form.
> when the user clicks submit the input is validated. If any fields are
> not acceptable the user clicks on a button to go back to the original
> form to correct the input. This all works fine until I try to
> incorporate a javascript to display a popup calendar which posts the
> selected date back to a field on the form. This script works fine in
> itself, however if the page is submitted after this script has run and
> other fields are not valid, then when I go back to the form ALL the
> data entered is cleared. I am fairly new to asp and at a lost as to
> what i am doing wrong.
>
> I would appreciate any pointers as to how I can correct this.
>
> My asp page is is follows:
>
> Handles database connects
> ' contains the Javascript to
> handle the popup window
>
> <% If (0 = Request.ServerVariables("CONTENT_LENGTH")) Then %>
>
>
" method= post
> name = example_form>
>
> ' VArious Input elements
> '
> hyperlink to javascript window to complete a field if required
>
> ' Validation of data input
>
>
> onClick="history.go(-1) "> ' button to go back to original form if
> invalid data found
>
> The cal_inc.asp is :
>
>
> and the ='mc_calendar.asp page which it calls is :
>
>
>
>
>
> Pick a calendar date...
>
>
>
>
> <% date_cursor=date_cursor+1 %>
> <% next %>
>
>
>
>
>
>
>
>
>
>
>
>
>
You can't rely on history.go(-1) to retain values in forms under any
circumstances. It may work in the version of browser you have on your
machine, with your setup, but it might not in mine.
You would be better off getting the form to post to itself. If it
validates, process the values, if not, show the form again with the posted
values:
<%
Sub showform
%>
Enter name:
value="<%=Request.Form("thename")%>">
<%
End Sub
If Request.Form("Action") = "Submit" Then 'user has submitted
'validate
If pass then
'Process values
Else 'if failed
showForm
End If
Else 'user has NOT submitted
showform
End If
%>
By the way, you should never refer to the request collection without
qualifying which one you are dealing with - Request.Form or
Request.QueryString. You are forcing a search of each collection in turn
until the correct one is found.
--
Mike Brind
Re: Problem when using javascript
am 10.12.2006 22:56:50 von anthonybrough
Hi Mike
Thanks for the reply.
I have taken your points on board and redesigned the page. It all works
well with the exception of Checkboxes. I have tried searhing here but
cannot seem to find a way to make the the form redisplay and show the
checked state of the checkbox.
In my original form I have the following:
when the form is posted I can get the value of the checkbox using:
strC1 = request.form("C1") which returns "ON" as expected.
however I cannot find a way to set the value back to the posted form.
I would be grateful of any assistance.
Regards
Tony
Mike Brind wrote:
> wrote in message
> news:1165699095.201469.142280@j44g2000cwa.googlegroups.com.. .
> >I have an asp page that has a form to collect user data in a form.
> > when the user clicks submit the input is validated. If any fields are
> > not acceptable the user clicks on a button to go back to the original
> > form to correct the input. This all works fine until I try to
> > incorporate a javascript to display a popup calendar which posts the
> > selected date back to a field on the form. This script works fine in
> > itself, however if the page is submitted after this script has run and
> > other fields are not valid, then when I go back to the form ALL the
> > data entered is cleared. I am fairly new to asp and at a lost as to
> > what i am doing wrong.
> >
> > I would appreciate any pointers as to how I can correct this.
> >
> > My asp page is is follows:
> >
> > Handles database connects
> > ' contains the Javascript to
> > handle the popup window
> >
> > <% If (0 = Request.ServerVariables("CONTENT_LENGTH")) Then %>
> >
> >
" method= post
> > name = example_form>
> >
> > ' VArious Input elements
> > '
> > hyperlink to javascript window to complete a field if required
> >
> > ' Validation of data input
> >
> >
> > onClick="history.go(-1) "> ' button to go back to original form if
> > invalid data found
> >
> > The cal_inc.asp is :
> >
> >
> > and the ='mc_calendar.asp page which it calls is :
> >
> >
> >
> >
> >
> > Pick a calendar date...
> >
> >
> >
> >
> > <% for i=1 to 42 %>
> > <% if WeekDay(new_now-(day(new_now)-1)+date_cursor)=1 then
> > if i>1 then %>
> >
> > <% end if %>
> >
> > <% end if %>
> >
> > <% if (date_cursor>=0 and date_cursor<=2) or (date_cursor>=3 and
> > date_cursor<=30 and day(new_now-(day(new_now)-1)+date_cursor)>3) then
> > %>
> >
> >
> >
> >
> >
> >
>
> You can't rely on history.go(-1) to retain values in forms under any
> circumstances. It may work in the version of browser you have on your
> machine, with your setup, but it might not in mine.
>
> You would be better off getting the form to post to itself. If it
> validates, process the values, if not, show the form again with the posted
> values:
>
> <%
> Sub showform
> %>
>
> Enter name:
> value="<%=Request.Form("thename")%>">
>
>
> <%
> End Sub
>
> If Request.Form("Action") = "Submit" Then 'user has submitted
> 'validate
> If pass then
> 'Process values
> Else 'if failed
> showForm
> End If
> Else 'user has NOT submitted
> showform
> End If
> %>
>
> By the way, you should never refer to the request collection without
> qualifying which one you are dealing with - Request.Form or
> Request.QueryString. You are forcing a search of each collection in turn
> until the correct one is found.
>
> --
> Mike Brind
Re: Problem when using javascript
am 11.12.2006 09:14:46 von Mike Brind
wrote in message
news:1165787810.716947.72030@79g2000cws.googlegroups.com...
>
> Mike Brind wrote:
>
>> wrote in message
>> news:1165699095.201469.142280@j44g2000cwa.googlegroups.com.. .
>> >I have an asp page that has a form to collect user data in a form.
>> > when the user clicks submit the input is validated. If any fields are
>> > not acceptable the user clicks on a button to go back to the original
>> > form to correct the input. This all works fine until I try to
>> > incorporate a javascript to display a popup calendar which posts the
>> > selected date back to a field on the form. This script works fine in
>> > itself, however if the page is submitted after this script has run and
>> > other fields are not valid, then when I go back to the form ALL the
>> > data entered is cleared. I am fairly new to asp and at a lost as to
>> > what i am doing wrong.
>> >
>> > I would appreciate any pointers as to how I can correct this.
>> >
>> > My asp page is is follows:
>> >
[snipped]
>>
>> You can't rely on history.go(-1) to retain values in forms under any
>> circumstances. It may work in the version of browser you have on your
>> machine, with your setup, but it might not in mine.
>>
>> You would be better off getting the form to post to itself. If it
>> validates, process the values, if not, show the form again with the
>> posted
>> values:
>>
>> <%
>> Sub showform
>> %>
>>
>> Enter name:
>> value="<%=Request.Form("thename")%>">
>>
>>
>> <%
>> End Sub
>>
>> If Request.Form("Action") = "Submit" Then 'user has submitted
>> 'validate
>> If pass then
>> 'Process values
>> Else 'if failed
>> showForm
>> End If
>> Else 'user has NOT submitted
>> showform
>> End If
>> %>
>>
>> By the way, you should never refer to the request collection without
>> qualifying which one you are dealing with - Request.Form or
>> Request.QueryString. You are forcing a search of each collection in turn
>> until the correct one is found.
>>
>> --
>> Mike Brind
>
> Hi Mike
>
> Thanks for the reply.
>
> I have taken your points on board and redesigned the page. It all works
> well with the exception of Checkboxes. I have tried searhing here but
> cannot seem to find a way to make the the form redisplay and show the
> checked state of the checkbox.
>
> In my original form I have the following:
>
>
> when the form is posted I can get the value of the checkbox using:
> strC1 = request.form("C1") which returns "ON" as expected.
> however I cannot find a way to set the value back to the posted form.
> I would be grateful of any assistance.
>
Request.Form("C1")="ON" Then Response.Write " checked" %> >