Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Is there a better way to do this?

Reply
Thread Tools

Is there a better way to do this?

 
 
Jerry
Guest
Posts: n/a
 
      03-15-2005
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
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      03-15-2005
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)

 
Reply With Quote
 
 
 
 
Jerry
Guest
Posts: n/a
 
      03-15-2005
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
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      03-15-2005
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!

<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)

 
Reply With Quote
 
Jerry
Guest
Posts: n/a
 
      03-15-2005
Evertjan. wrote:
> 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.

> <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
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      03-15-2005
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)

 
Reply With Quote
 
Jerry
Guest
Posts: n/a
 
      03-15-2005
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
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      03-15-2005
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.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

 
Reply With Quote
 
Jerry
Guest
Posts: n/a
 
      03-15-2005
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).


--
Jerry
 
Reply With Quote
 
Jerry
Guest
Posts: n/a
 
      03-15-2005
Jerry wrote:
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Parsing Binary Structures; Is there a better way / What is your way? Paul Rubin Python 5 08-06-2009 08:06 AM
Are there better ADSL modem routers out there? Bypass UK VOIP 28 01-12-2007 12:41 AM
Is splint really better than lint? Is there a better tool than splint? Peter Bencsik C Programming 2 09-21-2006 10:02 PM
Build a Better Blair (like Build a Better Bush, only better) Kenny Computer Support 0 05-06-2005 04:50 AM
There MUST be a better way! dwa ASP .Net 5 01-29-2004 02:07 AM



Advertisments