473,516 Members | 3,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there a better way to do this?

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
Jul 22 '05 #1
11 1162
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)

Jul 22 '05 #2
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
Jul 22 '05 #3
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)

Jul 22 '05 #4
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
Jul 22 '05 #5
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)

Jul 22 '05 #6
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
Jul 22 '05 #7
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)

Jul 22 '05 #8
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
Jul 22 '05 #9
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
Jul 22 '05 #10
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)

Jul 22 '05 #11
Evertjan. wrote:
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
Jul 22 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2507
by: ForHimself Every Man | last post by:
What's better about Rattlesnakes than Python. I'm sure there's something. What is it? This is not a troll. I'm a snake shooping and I want people's answers. I don't know beans about Rattlesnakes or have an preconceived ideas about them. I noticed, however, that everyone I talk to who are aware of Pythons are also afraid of...
10
7126
by: michael newport | last post by:
Dear friends of database(s), After 13 years of Ingres, I am now using Oracle. But is Oracle technically better than Ingres. I would be much obliged if anyone could shed some light on the above question. It would also be helpful if you could 'please' keep your comments on a
24
3409
by: Faith Dorell | last post by:
I really don´t like C.You can write better programs in BASIC than in C, if you don´t like this language. I don´t understand how C became so popular, although much better programming languages existed in the 70s or 80s or 90s. Pascal is much better.
39
2346
by: bazad | last post by:
Hi, I am not using C all the time. I have a general understanding of C and nothing else. The recent reply to use strlcpy and strlcat showed me that I am not aware of the best and safe techniques. Is there any place where I could learn more about safer and better C (on FreeBSD)? Thank you
2
2884
by: monkeydragon | last post by:
Which is better, using ReadFile/WriteFile or use fstream?
33
2525
by: Protoman | last post by:
Which is better for general-purpose programming, C or C++? My friend says C++, but I'm not sure. Please enlighten me. Thanks!!!!!
22
2686
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at programming. I tend to learn what is useful and gets the job done. I am always curious if there is some techique I don't know. I read books and study...
21
1715
by: gavino | last post by:
why?
3
3563
by: Ryan Liu | last post by:
Hi, Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than synchronous I/O? At least as good? When I don't concern about easy or difficult to write code, should I always use Async I/O?
43
1803
by: Pawel_Iks | last post by:
I've read somewhere that c++ is something more than better c ... then I talk with my friend and he claimed that c++ is nothing more than better c ... I tried to explain him that he was wrong but I forgot all arguments about it. Could someone told something about it?
0
7273
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7574
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3265
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.