Home All Groups Group Topic Archive Search About

Is there a better way to do this?



Author
15 Mar 2005 8:02 PM
Jerry
I'm creating a survey for our organization that consists of about 38
statements that need to be rated on a scale of 1 to 5. The survey is for
a very specific audience and all of the questions are required. I'm
using radio buttons for the ratings and am wondering if I'm handeling
this the best way to preserve the user's answers if they missed a
question and have to go back to answer.

Here is what I have (this would be for each question):
<%
dim arr1(4)

select case session("1")
    case "5" arr(4) = "SELECTED"
    case "4" arr(3) = "SELECTED"
    case "3" arr(2) = "SELECTED"
    case "2" arr(1) = "SELECTED"
    case "1" arr(0) = "SELECTED"
end select
%>

5<input type="radio" name="1" value="5"<%=arr(4)%>>
4<input type="radio" name="1" value="4"<%=arr(3)%>>
3<input type="radio" name="1" value="3"<%=arr(2)%>>
2<input type="radio" name="1" value="2"<%=arr(1)%>>
1<input type="radio" name="1" value="1"<%=arr(0)%>>

Is there a better, more efficient way to do this?

Thanks,

--
Jerry

Author
15 Mar 2005 8:21 PM
Evertjan.
Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:

> Here is what I have (this would be for each question):
> <%
> dim arr1(4)
>
> select case session("1")
>      case "5" arr(4) = "SELECTED"
>      case "4" arr(3) = "SELECTED"
>      case "3" arr(2) = "SELECTED"
>      case "2" arr(1) = "SELECTED"
>      case "1" arr(0) = "SELECTED"
> end select
> %>

"selected" should be "checked"

> 5<input type="radio" name="1" value="5"<%=arr(4)%>>
> 4<input type="radio" name="1" value="4"<%=arr(3)%>>
> 3<input type="radio" name="1" value="3"<%=arr(2)%>>
> 2<input type="radio" name="1" value="2"<%=arr(1)%>>
> 1<input type="radio" name="1" value="1"<%=arr(0)%>>
>
> Is there a better, more efficient way to do this?
>



<%
function sel(x)
        sel = ""
        if x = session("1") then sel = "checked"
end functon
%>

5 <input type="radio" name="1" value="5" <%=sel(5)%>>
4 <input type="radio" name="1" value="4" <%=sel(4)%>>
3 <input type="radio" name="1" value="3" <%=sel(3)%>>
2 <input type="radio" name="1" value="2" <%=sel(2)%>>
1 <input type="radio" name="1" value="1" <%=sel(1)%>>



--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Author
15 Mar 2005 8:52 PM
Jerry
Evertjan. wrote:
> <%
> function sel(x)
>         sel = ""
>         if x = session("1") then sel = "checked"
> end functon
> %>
>
> 5 <input type="radio" name="1" value="5" <%=sel(5)%>>
> 4 <input type="radio" name="1" value="4" <%=sel(4)%>>
> 3 <input type="radio" name="1" value="3" <%=sel(3)%>>
> 2 <input type="radio" name="1" value="2" <%=sel(2)%>>
> 1 <input type="radio" name="1" value="1" <%=sel(1)%>>
>

I tried to call the function like this:
<%
function sel(x)
    sel = ""
    if x = session("1") then sel = " checked"
end function

call sel(session("1"))
%>
5<input type="radio" name="1" value="5"<%=sel(5)%>>
4<input type="radio" name="1" value="4"<%=sel(4)%>>
3<input type="radio" name="1" value="3"<%=sel(3)%>>
2<input type="radio" name="1" value="2"<%=sel(2)%>>
1<input type="radio" name="1" value="1"<%=sel(1)%>>

I could not get it to work. I'm sorry, I'm not very familiar with ASP
functions. Could you point out what I'm doing wrong here?


--
Jerry
Author
15 Mar 2005 9:11 PM
Evertjan.
Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:

Show quote
> Evertjan. wrote:
>> <%
>> function sel(x)
>>          sel = ""
>>          if x = session("1") then sel = "checked"
>> end functon
>> %>
>>
>> 5 <input type="radio" name="1" value="5" <%=sel(5)%>>
>> 4 <input type="radio" name="1" value="4" <%=sel(4)%>>
>> 3 <input type="radio" name="1" value="3" <%=sel(3)%>>
>> 2 <input type="radio" name="1" value="2" <%=sel(2)%>>
>> 1 <input type="radio" name="1" value="1" <%=sel(1)%>>
>>
>
> I tried to call the function like this:
> <%
> function sel(x)
>      sel = ""
>      if x = session("1") then sel = " checked"
> end function
>

> call sel(session("1"))

No that call does not work.  the <%=sel(5)%> is the call


> %>
> 5<input type="radio" name="1" value="5"<%=sel(5)%>>

Why do you change my code? do not delete neccessary spaces!

<input type="radio" name="1" value="5" <%=sel(5)%>>


> 4<input type="radio" name="1" value="4"<%=sel(4)%>>
> 3<input type="radio" name="1" value="3"<%=sel(3)%>>
> 2<input type="radio" name="1" value="2"<%=sel(2)%>>
> 1<input type="radio" name="1" value="1"<%=sel(1)%>>
>
> I could not get it to work. I'm sorry, I'm not very familiar with ASP
> functions. Could you point out what I'm doing wrong here?

This NG usually and I certainly expect some familiarity or self
experiment with ASP.

Does a test.asp page with only:

<%="Hello World"%>

produce

Hello World

?


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Author
15 Mar 2005 9:24 PM
Jerry
Evertjan. wrote:
Show quote
> Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:
>
>
>>Evertjan. wrote:
>>
>>><%
>>>function sel(x)
>>>         sel = ""
>>>         if x = session("1") then sel = "checked"
>>>end functon
>>>%>
>>>
>>>5 <input type="radio" name="1" value="5" <%=sel(5)%>>
>>>4 <input type="radio" name="1" value="4" <%=sel(4)%>>
>>>3 <input type="radio" name="1" value="3" <%=sel(3)%>>
>>>2 <input type="radio" name="1" value="2" <%=sel(2)%>>
>>>1 <input type="radio" name="1" value="1" <%=sel(1)%>>
>>>
>>I tried to call the function like this:
>><%
>>function sel(x)
>>     sel = ""
>>     if x = session("1") then sel = " checked"
>>end function
>>
>
>
>>call sel(session("1"))
>
>
> No that call does not work.  the <%=sel(5)%> is the call
>
>
>
>>%>
>>5<input type="radio" name="1" value="5"<%=sel(5)%>>
>
>
> Why do you change my code? do not delete neccessary spaces!

It didn't work so I experimented a little.

Show quote
> <input type="radio" name="1" value="5" <%=sel(5)%>>
>
>
>>4<input type="radio" name="1" value="4"<%=sel(4)%>>
>>3<input type="radio" name="1" value="3"<%=sel(3)%>>
>>2<input type="radio" name="1" value="2"<%=sel(2)%>>
>>1<input type="radio" name="1" value="1"<%=sel(1)%>>
>>
>>I could not get it to work. I'm sorry, I'm not very familiar with ASP
>>functions. Could you point out what I'm doing wrong here?
>
>
> This NG usually and I certainly expect some familiarity or self
> experiment with ASP.

I'm familiar with ASP. I've just never used functions that much. My job
requires a little ASP coding but not much. The code example didn't work
so I experimented a little. Obviously I was going the wrong direction.

> Does a test.asp page with only:
>
> <%="Hello World"%>
>
> produce
>
> Hello World
>
> ?

<sigh>


--
Jerry
Author
15 Mar 2005 9:49 PM
Evertjan.
Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:

>> Does a test.asp page with only:
>>
>> <%="Hello World"%>
>>
>> produce
>>
>> Hello World
>>
>> ?
>
> <sigh>
>

This is not a joke.
It is a serious attemt to help you.


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Author
15 Mar 2005 9:54 PM
Jerry
Evertjan. wrote:
Show quote
> Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:
>
>
>>>Does a test.asp page with only:
>>>
>>><%="Hello World"%>
>>>
>>>produce
>>>
>>>Hello World
>>>
>>>?
>>
>><sigh>
>>
>
> This is not a joke.
> It is a serious attemt to help you.
>

The example above would produce "Hello World".


--
Jerry
Author
15 Mar 2005 10:05 PM
Evertjan.
Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:

Show quote
> Evertjan. wrote:
>> Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:
>>
>>
>>>>Does a test.asp page with only:
>>>>
>>>><%="Hello World"%>
>>>>
>>>>produce
>>>>
>>>>Hello World
>>>>
>>>>?
>>>
>>><sigh>
>>>
>>
>> This is not a joke.
>> It is a serious attemt to help you.
>>
>
> The example above would produce "Hello World".

Jerry, the question is not what is WOULD produce,
but it is the first debugging test
if your asp enging is working.

It seems, since as you profes,
your knowledge of asp functions is limited,
that serious debugging is necessary.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Author
15 Mar 2005 10:10 PM
Jerry
Evertjan. wrote:
Show quote
> Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:
>
>
>>Evertjan. wrote:
>>
>>>Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:
>>>
>>>
>>>
>>>>>Does a test.asp page with only:
>>>>>
>>>>><%="Hello World"%>
>>>>>
>>>>>produce
>>>>>
>>>>>Hello World
>>>>>
>>>>>?
>>>>
>>>><sigh>
>>>>
>>>This is not a joke.
>>>It is a serious attemt to help you.
>>>
>>
>>The example above would produce "Hello World".
>
>
> Jerry, the question is not what is WOULD produce,
> but it is the first debugging test
> if your asp enging is working.
>
> It seems, since as you profes,
> your knowledge of asp functions is limited,
> that serious debugging is necessary.
>

Ah, I didn't quite understand you earlier. The answer to your question
is yes, that does work. I have various other ASP pages on my website
that are also currently working (I just checked after reading your reply).


--
Jerry
Author
15 Mar 2005 10:19 PM
Jerry
Jerry wrote:
Show quote
> Evertjan. wrote:
>
>> Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:
>>
>>
>>> Evertjan. wrote:
>>>
>>>> Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:
>>>>
>>>>
>>>>
>>>>>> Does a test.asp page with only:
>>>>>>
>>>>>> <%="Hello World"%>
>>>>>>
>>>>>> produce
>>>>>> Hello World
>>>>>>
>>>>>> ?
>>>>>
>>>>>
>>>>> <sigh>
>>>>>
>>>> This is not a joke. It is a serious attemt to help you.
>>>>
>>>
>>> The example above would produce "Hello World".
>>
>>
>>
>> Jerry, the question is not what is WOULD produce, but it is the first
>> debugging test if your asp enging is working.
>>
>> It seems, since as you profes, your knowledge of asp functions is
>> limited, that serious debugging is necessary.
>>
>
> Ah, I didn't quite understand you earlier. The answer to your question
> is yes, that does work. I have various other ASP pages on my website
> that are also currently working (I just checked after reading your reply).
>
>

This worked:

<%
function sel(x)
    sel = ""
    if (x*1) = (session("1")*1) then sel = "checked"
end function
%>
5<input type="radio" name="1" value="5" <%=sel(5)%>>
4<input type="radio" name="1" value="4" <%=sel(4)%>>
3<input type="radio" name="1" value="3" <%=sel(3)%>>
2<input type="radio" name="1" value="2" <%=sel(2)%>>
1<input type="radio" name="1" value="1" <%=sel(1)%>>

I think the problem was that session("1") was not numeric so it didn't
equal the numeric value of x.


--
Jerry
Author
15 Mar 2005 10:26 PM
Evertjan.
Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:

> Ah, I didn't quite understand you earlier. The answer to your question
> is yes, that does work. I have various other ASP pages on my website
> that are also currently working (I just checked after reading your
> reply).
>
>

Than the next question is, does this work:

=========== test.asp =============

<%
function sel(x)
        sel = ""
        if x = session("1") then sel = "checked"
end function

session("1") = "myTest"
%>

myTest: <%=sel("myTest")%>
<br>
yourTest: <%=sel("yourTest")%>

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

on my system it shows:

myTest: checked
yourTest:

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Author
15 Mar 2005 10:36 PM
Jerry
Evertjan. wrote:
Show quote
> Jerry wrote on 15 mrt 2005 in microsoft.public.inetserver.asp.general:
>
>
>>Ah, I didn't quite understand you earlier. The answer to your question
>>is yes, that does work. I have various other ASP pages on my website
>>that are also currently working (I just checked after reading your
>>reply).
>>
>>
>
>
> Than the next question is, does this work:
>
> =========== test.asp =============
>
> <%
> function sel(x)
>         sel = ""
>         if x = session("1") then sel = "checked"
> end function
>
> session("1") = "myTest"
> %>
>
> myTest: <%=sel("myTest")%>
> <br>
> yourTest: <%=sel("yourTest")%>
>
> ============================
>
> on my system it shows:
>
> myTest: checked
> yourTest:
>

I get the same results.


--
Jerry

AddThis Social Bookmark Button