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
>>> %>
>>> <input type="checkbox" name="C1_<%=i%>" " id="chk_<%=i%>" value="ON">
>>> <% else %>
>>>
>>> <input type="checkbox" name="C1_<%=i%>" " id="chk_<%=i%>" value="ON"
>>> 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") %>
>> <input type="checkbox" name="C1_<%=i%>" id="chk_<%=i%>"
>> <% 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)
|