ASP - Session - checkbox

ASP - Session - checkbox

am 24.08.2007 20:21:57 von Charlotte

Hi,

I have a problem with a ASP-script, can somewone help me ?

here is what I've got:

mypage.asp :

.... code ...
<%
If Request.Form("zzz") = "brussels" Then
Session("city") = "brussels"
End If
If Request.Form("zzz") = "antwerp" Then
Session("city") = "antwerp"
End If
If Request.Form("zzz") = "london" Then
Session("city") = "london"
End If
If Request.Form("zzz") = "newyork" Then
Session("city") = "newyork"
End If
%>
.... code ...







Session("city") = "brussels" Then %>checked<% End If %>>
Session("city") = "antwerp" Then %>checked<% End If %>>
Session("city") = "london" Then %>checked<% End If %>>
Session("city") = "newyork" Then %>checked<% End If %>>



.... code ...

So, when the submit-button is clicked and only 1 checkbox is checked, no
problem
the page returns and that checkbox is checked

But when 2 are 3 or ... checkboxes are checked and the page returns
none of the checkboxes are checked
so I want that the checkboxes who were checked
are still be checked after rebuilding the page

I've put a response.write session("city") and the output is (for example)
brussels, antwerp, london

of course it won't work because
If Session("city") = "brussels" Then....
and the session isn't brussels, but
brussels, antwerp, london

so I think that the session must be "split"
so afterwards I can check of the session is that city
and the checkbox of that city must be checked

can somebody give me a script that will do the job
thanks

Charlotte

Re: ASP - Session - checkbox

am 24.08.2007 20:49:59 von exjxw.hannivoort

Charlotte wrote on 24 aug 2007 in
microsoft.public.inetserver.asp.general:

>
> Hi,
>
> I have a problem with a ASP-script, can somewone help me ?
>
> here is what I've got:
>
> mypage.asp :
>
> ... code ...
> <%
> If Request.Form("zzz") = "brussels" Then
> Session("city") = "brussels"
> End If
> If Request.Form("zzz") = "antwerp" Then
> Session("city") = "antwerp"
> End If
> If Request.Form("zzz") = "london" Then
> Session("city") = "london"
> End If
> If Request.Form("zzz") = "newyork" Then
> Session("city") = "newyork"
> End If
> %>
> ... code ...
>


>
>
>
>
>
>
> Session("city") = "brussels" Then %>checked<% End If %>>
> Session("city") = "antwerp" Then %>checked<% End If %>>
> Session("city") = "london" Then %>checked<% End If %>>
> Session("city") = "newyork" Then %>checked<% End If %>>

>

>

> ... code ...
>
> So, when the submit-button is clicked and only 1 checkbox is checked,
> no problem
> the page returns and that checkbox is checked
>
> But when 2 are 3 or ... checkboxes are checked and the page returns
> none of the checkboxes are checked
> so I want that the checkboxes who were checked
> are still be checked after rebuilding the page
>
> I've put a response.write session("city") and the output is (for
> example) brussels, antwerp, london
>
> of course it won't work because
> If Session("city") = "brussels" Then....
> and the session isn't brussels, but
> brussels, antwerp, london
>
> so I think that the session must be "split"
> so afterwards I can check of the session is that city
> and the checkbox of that city must be checked

Try this, there is no need for session variables in the bare case:

========== test1.asp ===========


name='brussels'
<% If Request.Form("brussels")<>"" Then %>
checked
<% End If %>
> brussels


name='antwerp'
<% If Request.Form("antwerp")<>"" Then %>
checked
<% End If %>
> antwerp


name='london'
<% If Request.Form("london")<>"" Then %>
checked
<% End If %>
> london


name='newyork'
<% If Request.Form("newyork")<>"" Then %>
checked
<% End If %>
> newyork




===============================

An even nicer way to do this, I think:

========== test2.asp ===========
<%
function makeCheckbox(nm)
r = " If Request.Form(nm)<>"" Then
r = r & "checked "
End If
r = r & "> "&nm&"
"
makeCheckbox = r
end function
%>


<% = makeCheckbox("brussels") %>
<% = makeCheckbox("antwerp") %>
<% = makeCheckbox("london") %>
<% = makeCheckbox("newyork") %>


===============================



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: ASP - Session - checkbox

am 24.08.2007 21:29:46 von Charlotte

"Evertjan." schreef in bericht
news:Xns9996D3EC7A7C3eejj99@194.109.133.242...
> Charlotte wrote on 24 aug 2007 in
> microsoft.public.inetserver.asp.general:
>
>>
>> Hi,
>>
>> I have a problem with a ASP-script, can somewone help me ?
>>
>> here is what I've got:
>>
>> mypage.asp :
>>
>> ... code ...
>> <%
>> If Request.Form("zzz") = "brussels" Then
>> Session("city") = "brussels"
>> End If
>> If Request.Form("zzz") = "antwerp" Then
>> Session("city") = "antwerp"
>> End If
>> If Request.Form("zzz") = "london" Then
>> Session("city") = "london"
>> End If
>> If Request.Form("zzz") = "newyork" Then
>> Session("city") = "newyork"
>> End If
>> %>
>> ... code ...
>>


>>
>>
>>
>>
>>
>>
>> Session("city") = "brussels" Then %>checked<% End If %>>
>> Session("city") = "antwerp" Then %>checked<% End If %>>
>> Session("city") = "london" Then %>checked<% End If %>>
>> Session("city") = "newyork" Then %>checked<% End If %>>

>>

>>

>> ... code ...
>>
>> So, when the submit-button is clicked and only 1 checkbox is checked,
>> no problem
>> the page returns and that checkbox is checked
>>
>> But when 2 are 3 or ... checkboxes are checked and the page returns
>> none of the checkboxes are checked
>> so I want that the checkboxes who were checked
>> are still be checked after rebuilding the page
>>
>> I've put a response.write session("city") and the output is (for
>> example) brussels, antwerp, london
>>
>> of course it won't work because
>> If Session("city") = "brussels" Then....
>> and the session isn't brussels, but
>> brussels, antwerp, london
>>
>> so I think that the session must be "split"
>> so afterwards I can check of the session is that city
>> and the checkbox of that city must be checked
>
> Try this, there is no need for session variables in the bare case:
>
> ========== test1.asp ===========
>

>
> > name='brussels'
> <% If Request.Form("brussels")<>"" Then %>
> checked
> <% End If %>
>> brussels

>
> > name='antwerp'
> <% If Request.Form("antwerp")<>"" Then %>
> checked
> <% End If %>
>> antwerp

>
> > name='london'
> <% If Request.Form("london")<>"" Then %>
> checked
> <% End If %>
>> london

>
> > name='newyork'
> <% If Request.Form("newyork")<>"" Then %>
> checked
> <% End If %>
>> newyork

>
>

>
> ===============================
>
> An even nicer way to do this, I think:
>
> ========== test2.asp ===========
> <%
> function makeCheckbox(nm)
> r = " > If Request.Form(nm)<>"" Then
> r = r & "checked "
> End If
> r = r & "> "&nm&"
"
> makeCheckbox = r
> end function
> %>
>
>

> <% = makeCheckbox("brussels") %>
> <% = makeCheckbox("antwerp") %>
> <% = makeCheckbox("london") %>
> <% = makeCheckbox("newyork") %>
>
>

> ===========
> Evertjan.
> The Netherlands.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Evertjan,

ik stap dan maar gelijk over naar het Nederlands

bedankt voor uw antwoord, doch één ding heb ik niet vermeld
en dat is dat de content van die sessievariabele ook zou gebruikt worden in
een andere pagina
om daar een select mee te maken (om te filteren)

SQL = "SELECT * FROM xxxxxxxx "
SQL = SQL & "WHERE datum >= #" & start_periode & "# "
SQL = SQL & "AND datum <= #" & einde_periode & "# "
SQL = SQL & "AND ........filtering volgens content van de
variabele..........."

kortom, dat enkel de record van die stad of steden uit de database worden
gehaald

een idee ?

Charlotte
België

Re: ASP - Session - checkbox

am 24.08.2007 22:53:49 von exjxw.hannivoort

Charlotte wrote on 24 aug 2007 in
microsoft.public.inetserver.asp.general:

>> ========== test2.asp ===========
>> <%
>> function makeCheckbox(nm)
>> r = " >> If Request.Form(nm)<>"" Then
>> r = r & "checked "
>> End If
>> r = r & "> "&nm&"
"
>> makeCheckbox = r
>> end function
>> %>
>>
>>


>> <% = makeCheckbox("brussels") %>
>> <% = makeCheckbox("antwerp") %>
>> <% = makeCheckbox("london") %>
>> <% = makeCheckbox("newyork") %>
>>
>>

>> ===========
>> Evertjan.
>> The Netherlands.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Evertjan,
>
> ik stap dan maar gelijk over naar het Nederlands
>
> bedankt voor uw antwoord, doch ‚‚n ding heb ik niet vermeld
> en dat is dat de content van die sessievariabele ook zou gebruikt
> worden in een andere pagina
> om daar een select mee te maken (om te filteren)


Ja, maar dat maakt toch niet uit, je kan altijd een session variabel
gebruiken om iets op te slaan, maar als je meer mogelijkheden tegelijk
wil opslaan, dan kan je dat niet in één variabele stoppen [of je moet een
grapje uithalen]

>
> SQL = "SELECT * FROM xxxxxxxx "
> SQL = SQL & "WHERE datum >= #" & start_periode & "# "
> SQL = SQL & "AND datum <= #" & einde_periode & "# "
> SQL = SQL & "AND ........filtering volgens content van de
> variabele..........."

Sorry, maar daar staat veel meer in, dat hangt helemaal af van de opbouw
van de database. Wil je meer dan 1 record ophalen als je meer dan één
checkbox hebt aanstaan?

> kortom, dat enkel de record van die stad of steden uit de database
> worden gehaald
>
> een idee ?

Had weinig met die eerste vraag te maken, en een sessie variabel heb je
daar dan toch ook niet strikt voor nodig?

Zet gewoon de gevonden cities in een array en:

SQL = "... WHERE city = " & cities(0) & " OR city = " & cities(1) &_
" OR city = " & cities(3) & " .... ;"

Als het field "city" dan uniek is krijg je voor iedere city maximaal één
record.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: ASP - Session - checkbox

am 18.09.2007 21:28:52 von Shelly

"Evertjan." wrote in message
news:Xns9996E8EB1A1E6eejj99@194.109.133.242...
> SQL = "... WHERE city = " & cities(0) & " OR city = " & cities(1) &_
> " OR city = " & cities(3) & " .... ;"
>

How about?
....WHERE city IN (cities(0), cities(1), ...etc)