I've written an asp page in order to handle an array for a simple
shopping cart. What I am trying to accomplish is "deleting" one or
more of the items by basically setting one of the array values to 0 so
that the item won't be considered for further use. I've been
successful in determining which checkboxes are checked but it seems
that my code will set all the items to zero because my conditional
statement isn't working as I expect. Any suggestions are appreciated.
Re: subroutine issue in asp page
am 08.08.2007 10:15:11 von exjxw.hannivoort
sjsean wrote on 08 aug 2007 in microsoft.public.inetserver.asp.general:
> I've written an asp page in order to handle an array for a simple
> shopping cart. What I am trying to accomplish is "deleting" one or
> more of the items by basically setting one of the array values to 0 so
> that the item won't be considered for further use. I've been
> successful in determining which checkboxes are checked but it seems
> that my code will set all the items to zero because my conditional
> statement isn't working as I expect. Any suggestions are appreciated.
>
>
As asp code only prepares the html stream for the client/browser,
it is finshed before the client starts executing
the clientside defunct sub.
Please rethink what you want to do.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Re: subroutine issue in asp page
am 09.08.2007 03:16:46 von sjsean
On Aug 8, 1:15 am, "Evertjan." wrote:
> sjseanwrote on 08 aug 2007 in microsoft.public.inetserver.asp.general:
>
> > I've written an asp page in order to handle an array for a simple
> > shopping cart. What I am trying to accomplish is "deleting" one or
> > more of the items by basically setting one of the array values to 0 so
> > that the item won't be considered for further use. I've been
> > successful in determining which checkboxes are checked but it seems
> > that my code will set all the items to zero because my conditional
> > statement isn't working as I expect. Any suggestions are appreciated.
>
> >
>
> As asp code only prepares the html stream for the client/browser,
> it is finshed before the client starts executing
> the clientside defunct sub.
>
> Please rethink what you want to do.
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)
That is essentially what I had determined, but can anyone offer an
alternative approach to solving my initial problem? Would there be a
way to update an array so that certain items are no longer "active".
How would one go about using a checkbox to make the item inactive in a
sense? I know with javascript there are more possibilities to remove
the item from the array, but I'm not as skilled in that language and I
think I would still suffer the same issues as I do now. Is the only
answer to post the form back to itself and update the values that
way?
thanks for any suggestions.
Re: subroutine issue in asp page
am 09.08.2007 08:29:26 von Rob Parsons
Hi sjsean,
When updateing from your session array back to the client page/form.
<% for i = 0 to Session("cartMaxUsed")
if cartArray(13,i)=0 then
%>
<% else %>
checked>
<% end if %>
When reading from your shopping cart form and updating your session array...
<% for i = 0 to Session("cartMaxUsed")
if request("C1_" & i) = "ON" then
cartArray(13,i) = 1
else
cartArray(13,i)=0
end if
'''''''' Regards.
"sjsean" wrote in message
news:1186622206.197743.295600@i13g2000prf.googlegroups.com.. .
> On Aug 8, 1:15 am, "Evertjan." wrote:
>> sjseanwrote on 08 aug 2007 in microsoft.public.inetserver.asp.general:
>>
>> > I've written an asp page in order to handle an array for a simple
>> > shopping cart. What I am trying to accomplish is "deleting" one or
>> > more of the items by basically setting one of the array values to 0 so
>> > that the item won't be considered for further use. I've been
>> > successful in determining which checkboxes are checked but it seems
>> > that my code will set all the items to zero because my conditional
>> > statement isn't working as I expect. Any suggestions are appreciated.
>>
>> >
>>
>> As asp code only prepares the html stream for the client/browser,
>> it is finshed before the client starts executing
>> the clientside defunct sub.
>>
>> Please rethink what you want to do.
>>
>> --
>> Evertjan.
>> The Netherlands.
>> (Please change the x'es to dots in my emailaddress)
>
> That is essentially what I had determined, but can anyone offer an
> alternative approach to solving my initial problem? Would there be a
> way to update an array so that certain items are no longer "active".
> How would one go about using a checkbox to make the item inactive in a
> sense? I know with javascript there are more possibilities to remove
> the item from the array, but I'm not as skilled in that language and I
> think I would still suffer the same issues as I do now. Is the only
> answer to post the form back to itself and update the values that
> way?
>
> thanks for any suggestions.
>
Re: subroutine issue in asp page
am 09.08.2007 09:55:54 von exjxw.hannivoort
Rob ^_^ wrote on 09 aug 2007 in microsoft.public.inetserver.asp.general:
> <% for i = 0 to Session("cartMaxUsed")
> if cartArray(13,i)=0 then
> %>
>
> <% else %>
>
>
> checked>
> <% end if %>
What does that extra " afer the name=".." do???
I would not use the value="ON" of it is not checked.
I would not use a set value at all, since "on" is default,
and testing for empty string for not-checked is even simpler.
It can be done more easily like this:
<% for i = 0 to Session("cartMaxUsed") %>
<% if cartArray(13,i)<>0 then reasponse.write " checked" %>>
<% next %>
> <% for i = 0 to Session("cartMaxUsed")
> if request("C1_" & i) = "ON" then
This is dangerous using the default request object.
decide if your form is using method='post' or not.
> cartArray(13,i) = 1
Just entering true or false in the array
is also the more logical way to go.
> else
> cartArray(13,i) = 0
> end if
<%
for i = 0 to Session("cartMaxUsed")
cartArray(13,i) = request.form("C1_" & i) <> ""
next
%>
If you need the boolean array value later, just do:
<%
if cartArray(13,5) then ....
%>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Re: subroutine issue in asp page
am 09.08.2007 11:05:31 von Rob Parsons
Hi Evertjan,
np. I do not intend to supply a solution, Only to butter the mind to
explore. My code example was written on the top of my head, without the
benefit of an IDE or a test plan.
Regards.
"Evertjan." wrote in message
news:Xns99876507AB375eejj99@194.109.133.242...
> Rob ^_^ wrote on 09 aug 2007 in microsoft.public.inetserver.asp.general:
>
>> <% for i = 0 to Session("cartMaxUsed")
>> if cartArray(13,i)=0 then
>> %>
>>
>> <% else %>
>>
>>
>> checked>
>> <% end if %>
>
> What does that extra " afer the name=".." do???
>
> I would not use the value="ON" of it is not checked.
> I would not use a set value at all, since "on" is default,
> and testing for empty string for not-checked is even simpler.
>
> It can be done more easily like this:
>
> <% for i = 0 to Session("cartMaxUsed") %>
>
> <% if cartArray(13,i)<>0 then reasponse.write " checked" %>>
> <% next %>
>
>> <% for i = 0 to Session("cartMaxUsed")
>> if request("C1_" & i) = "ON" then
>
> This is dangerous using the default request object.
> decide if your form is using method='post' or not.
>
>> cartArray(13,i) = 1
>
> Just entering true or false in the array
> is also the more logical way to go.
>
>> else
>> cartArray(13,i) = 0
>> end if
>
> <%
> for i = 0 to Session("cartMaxUsed")
> cartArray(13,i) = request.form("C1_" & i) <> ""
> next
> %>
>
> If you need the boolean array value later, just do:
>
> <%
> if cartArray(13,5) then ....
> %>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)
Re: subroutine issue in asp page
am 09.08.2007 11:14:34 von exjxw.hannivoort
Rob ^_^ wrote on 09 aug 2007 in microsoft.public.inetserver.asp.general:
> "Evertjan." wrote in message
> news:Xns99876507AB375eejj99@194.109.133.242...
>> Rob ^_^ wrote on 09 aug 2007 in microsoft.public.inetserver.asp.general:
>>
>>> <% for i = 0 to Session("cartMaxUsed")
>>> if cartArray(13,i)=0 then
>>> %>
>>>
>>> <% else %>
>>>
>>>
>>> checked>
>>> <% end if %>
>>
>> What does that extra " afer the name=".." do???
>>
>> I would not use the value="ON" of it is not checked.
>> I would not use a set value at all, since "on" is default,
>> and testing for empty string for not-checked is even simpler.
>>
>> It can be done more easily like this:
>>
>> <% for i = 0 to Session("cartMaxUsed") %>
>>
>> <% if cartArray(13,i)<>0 then reasponse.write " checked" %>>
>> <% next %>
>>
>>> <% for i = 0 to Session("cartMaxUsed")
>>> if request("C1_" & i) = "ON" then
>>
>> This is dangerous using the default request object.
>> decide if your form is using method='post' or not.
>>
>>> cartArray(13,i) = 1
>>
>> Just entering true or false in the array
>> is also the more logical way to go.
>>
>>> else
>>> cartArray(13,i) = 0
>>> end if
>>
>> <%
>> for i = 0 to Session("cartMaxUsed")
>> cartArray(13,i) = request.form("C1_" & i) <> ""
>> next
>> %>
>>
>> If you need the boolean array value later, just do:
>>
>> <%
>> if cartArray(13,5) then ....
>> %>
> Hi Evertjan,
> np.
??
> I do not intend to supply a solution, Only to butter the mind to
> explore. My code example was written on the top of my head, without the
> benefit of an IDE or a test plan.
My posting was not ment to critisize your action,
only to improve on some code, as I see it.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Re: subroutine issue in asp page
am 09.08.2007 18:25:56 von Dave Anderson
"Evertjan." wrote:
> I would not use the value="ON" of it is not checked.
> I would not use a set value at all, since "on" is default,
> and testing for empty string for not-checked is even simpler.
Even more to the point, you can examine Request.Form(ElementName).Count.
This is especially graceful in JScript:
if (Request.Form(ElementName).Count) ... // it is checked
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Re: subroutine issue in asp page
am 17.08.2007 08:15:34 von Vicky
Hi sjsean,
You can use Ajax for this.
when you click on a checkbox, call a asp page in background, that will
update the session variable and will return you the string or XML
file.
In this way you will not need to reload the page each time you update
something.
sjsean wrote:
> I've written an asp page in order to handle an array for a simple
> shopping cart. What I am trying to accomplish is "deleting" one or
> more of the items by basically setting one of the array values to 0 so
> that the item won't be considered for further use. I've been
> successful in determining which checkboxes are checked but it seems
> that my code will set all the items to zero because my conditional
> statement isn't working as I expect. Any suggestions are appreciated.
>
>