In ASP and using Ms access.
I have a form which asks users to input some details. The details entered by the user will stored in a access database and also there is a calculation based on the input. The results of the overall score should display to the user inmediatly and that result also should be stored in the database, I will explain this by a small example.
Age : ............
Years as Employee : .........
If the user enter age as 15 then points = 5.
Between 15 - 30 then points = 10.
Aboove 30 then points = 20.
If the user is an Employee for 2 yrs then points = 5
yrs 2 - 4 thne points = 10
Above 4 then points = 30.
If an user put his age as 31 and been employee for 3 years his points = 30.
Results also using conditions.
If points < 20
Bad
If points between 20 - 30
Avarage
Above 30
Good.
How can I allocate points for each fields in asp. Do I have to use Javascript ir can be done in ASP...
How to store the overall score in the database...
Anbody can give any idea for this..
First give me a rough idea. I ll try to implement this.
Thank you.
4 2336
Hi,
You can do it this way , e.g.
Asp page called as Defualt.asp is containing user details and after submitting the data you are going to another page called as StoreResults.asp.
On StoreResults.asp you will write the code -
<%
-
Dim Age
-
Dim Noofyears
-
Dim points
-
-
Age = Request.Form("Age")
-
Noofyears = Request.Form("Noofyears")
-
-
If Age = 15 then
-
points = 5
-
else if Age >15 and Age <31 then
-
points = 10
-
else if Age >31 then
-
points = 20
-
else if Noofyears =2 then
-
points = 5
-
else if Noofyears >2 and Noofyears <5 then
-
points = 10
-
else if Noofyears >4 then
-
points = 30
-
else if Age =31 and Noofyears =3 then
-
points = 30
-
end if
-
-
'''''Calculate Result
-
If points < 20
-
Result = Bad
-
If points> 20 and points< 31
-
Result =Avarage
-
If points >31
-
Result =Good
-
-
'''''''Now store the result into db
-
Dim sql
-
Dim con
-
con= Server.CreateObject("Adodb.Connection")
-
con.connectionstring ="....."
-
con.open
-
sql = "Insert into tablename score ,result values(points, result)"
-
con.execute(sql)
-
con.close
-
%>
-
In ASP and using Ms access.
I have a form which asks users to input some details. The details entered by the user will stored in a access database and also there is a calculation based on the input. The results of the overall score should display to the user inmediatly and that result also should be stored in the database, I will explain this by a small example.
Age : ............
Years as Employee : .........
If the user enter age as 15 then points = 5.
Between 15 - 30 then points = 10.
Aboove 30 then points = 20.
If the user is an Employee for 2 yrs then points = 5
yrs 2 - 4 thne points = 10
Above 4 then points = 30.
If an user put his age as 31 and been employee for 3 years his points = 30.
Results also using conditions.
If points < 20
Bad
If points between 20 - 30
Avarage
Above 30
Good.
How can I allocate points for each fields in asp. Do I have to use Javascript ir can be done in ASP...
How to store the overall score in the database...
Anbody can give any idea for this..
First give me a rough idea. I ll try to implement this.
Thank you.
Thanks.
storeResults.asp -
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
-
<html>
-
<head>
-
<title>Result</title>
-
</head>
-
-
<body>
-
<%
-
Dim fbName, fbNic, fbAge, fbNoofyears, fbPoints, fbResult
-
-
fbName = Request.Form("textname")
-
fbNic = Request.Form("textnic")
-
fbAge = Request.Form("textage")
-
fbNoofyears = Request.Form("textEYrs")
-
-
-
If fbAge = 15 then
-
fbPoints = 5
-
else if fbAge > 15 and fbAge < 31 then
-
fbPoints = 10
-
else if fbAge > 31 then
-
fbPoints = 20
-
-
if fbNoofyears =2 then
-
fbPoints = 5
-
else if fbNoofyears > 2 and fbNoofyears <4 then
-
fbPoints = 5
-
else if fbNoofyears >= 4 then
-
fbPoints = 30
-
end if
-
end if
-
end if
-
end if
-
end if
-
end if
-
'''''Calculate Result
-
If fbPoints < 20 Then
-
fbResult = Bad
-
Response.write("Bad")
-
else If fbPoints > 19 and fbPoints < 31 Then
-
fbResult =Avarage
-
Response.write("Average")
-
else If fbPoints > 31 Then
-
fbResult =Good
-
Response.write("Good")
-
end if
-
end if
-
end if
-
-
Dim sql
-
Dim cn
-
-
set cn=server.CreateObject("ADODB.Connection")
-
path=server.MapPath(".")
-
cn.open "Driver=Microsoft Access Driver (*.mdb);DBQ="&path&"/admincp/dbase/newdata.mdb"
-
-
sql = "insert into score (Name, Nic, Age, NoOfYears, Points, Result) values ('" & _
-
fbName & "', '" & fbNic & "', '" & fbAge & "', '" & fbNoofyears & "', '" & fbPoints & "', '" & fbResult & "')"
-
-
-
cn.execute(sql)
-
cn.close
-
%>
-
-
</body>
-
</html>
-
This is the coding I wrote using your explanation. but there are some problem
1. In the databse Results is not stored. All others fields are ok. I didnt get any errors.
2. If else not giving the correct output I wish to get.
As I mentioned in the previous post what I need is if the user enter his age as 18 points given to that is 10.
then the same user enter working yrs as 4 then the points givenn to him is 30.
Finally total points = 10 + 30 = 40.
This condition not giving that output.
I couldnt find the correct one.
3. Did I use the endif in the correct way?
Please correct my mistakes.
Thank you.
Hi ,
If you want to make the addition of all the points then modify the code in the If conditions like this -
-
If fbAge = 15 then
-
fbPoints = fbPoints + 5
-
end
-
-
if fbAge > 15 and fbAge < 31 then
-
fbPoints = fbPoints + 10
-
end if
-
-
if fbAge > 31 then
-
fbPoints = fbPoints+20
-
end if
-
-
if fbNoofyears =2 then
-
fbPoints = fbPoints+5
-
end if
-
-
if fbNoofyears > 2 and fbNoofyears <4 then
-
fbPoints = fbPoints+ 5
-
end if
-
-
if fbNoofyears >= 4 then
-
fbPoints = fbPoints +30
-
end if
After calculating the Points , please check what the value for Result is coming before inseting into the database.
Thanks.
storeResults.asp -
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
-
<html>
-
<head>
-
<title>Result</title>
-
</head>
-
-
<body>
-
<%
-
Dim fbName, fbNic, fbAge, fbNoofyears, fbPoints, fbResult
-
-
fbName = Request.Form("textname")
-
fbNic = Request.Form("textnic")
-
fbAge = Request.Form("textage")
-
fbNoofyears = Request.Form("textEYrs")
-
-
-
If fbAge = 15 then
-
fbPoints = 5
-
else if fbAge > 15 and fbAge < 31 then
-
fbPoints = 10
-
else if fbAge > 31 then
-
fbPoints = 20
-
-
if fbNoofyears =2 then
-
fbPoints = 5
-
else if fbNoofyears > 2 and fbNoofyears <4 then
-
fbPoints = 5
-
else if fbNoofyears >= 4 then
-
fbPoints = 30
-
end if
-
end if
-
end if
-
end if
-
end if
-
end if
-
'''''Calculate Result
-
If fbPoints < 20 Then
-
fbResult = Bad
-
Response.write("Bad")
-
else If fbPoints > 19 and fbPoints < 31 Then
-
fbResult =Avarage
-
Response.write("Average")
-
else If fbPoints > 31 Then
-
fbResult =Good
-
Response.write("Good")
-
end if
-
end if
-
end if
-
-
Dim sql
-
Dim cn
-
-
set cn=server.CreateObject("ADODB.Connection")
-
path=server.MapPath(".")
-
cn.open "Driver=Microsoft Access Driver (*.mdb);DBQ="&path&"/admincp/dbase/newdata.mdb"
-
-
sql = "insert into score (Name, Nic, Age, NoOfYears, Points, Result) values ('" & _
-
fbName & "', '" & fbNic & "', '" & fbAge & "', '" & fbNoofyears & "', '" & fbPoints & "', '" & fbResult & "')"
-
-
-
cn.execute(sql)
-
cn.close
-
%>
-
-
</body>
-
</html>
-
This is the coding I wrote using your explanation. but there are some problem
1. In the databse Results is not stored. All others fields are ok. I didnt get any errors.
2. If else not giving the correct output I wish to get.
As I mentioned in the previous post what I need is if the user enter his age as 18 points given to that is 10.
then the same user enter working yrs as 4 then the points givenn to him is 30.
Finally total points = 10 + 30 = 40.
This condition not giving that output.
I couldnt find the correct one.
3. Did I use the endif in the correct way?
Please correct my mistakes.
Thank you.
Hi,
If you want to get the total of all the points then write it this way ,
e.g.
If fbAge = 15 then
fbPoints = fbPoints + 5
end if
if fbAge > 15 and fbAge < 31 then
fbPoints = fbPoints + 10
end if
if fbAge > 31 then
fbPoints = fbPoints + 20
end if
if fbNoofyears =2 then
fbPoints = fbPoints + 5
end if
if fbNoofyears > 2 and fbNoofyears <4 then
fbPoints = fbPoints + 5
end if
if fbNoofyears >= 4 then
fbPoints = fbPoints + 30
end if
Also , after calculating the value for for Points , please check the value of Result before inserting into the database using Response.Write.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Phil Powell |
last post by:
Relevancy scores are normally defined by a MySQL query on a table that
has a fulltext index. The rules for relevancy scoring will exclude
certain words due to their being too short (minimum...
|
by: Cardman |
last post by:
Greetings,
I am trying to solve a problem that has been inflicting my self
created Order Forms for a long time, where the problem is that as I
cannot reproduce this error myself, then it is...
|
by: Sven Neuberg |
last post by:
Hi,
I have been handed the task of updating and maintaining a web
application, written in ASP and Javascript, that takes complex
user inputs in HTML form and submits them to server-side ASP...
|
by: Uday |
last post by:
Hi everyone,
I have a ASP page that triggers a db-side stored procedure. At the end of
the procedure, it spits out a log file, that this ASP page reads and displays
for the users.
But the...
|
by: Rich_C |
last post by:
I'm sure this is very simple, but I have very little experience with
javascript -- and what I do know isn't helping me here.
I have a simple form where users can enter a quantity (qty) and cost...
|
by: lawton |
last post by:
Source: this is an access 2003 question
My knowledge level: reading books, internet, and trial & error; no formal training
I'm trying to get a running sum of what's filtered in a subform which is...
|
by: Atul |
last post by:
Hi
Theres a website that books hotels . user enters the information and
according to that results are displayed to the user.Let it be website
A.
Now I want to create a new project with...
|
by: CrostonScottish |
last post by:
Has anybody got any ideas or nifty code for calculating the median value in a form.
I currently have a database which we use for post-course evaluations. Part of the evaluation asks the attendees...
|
by: hamishmcgee |
last post by:
Ok, so for a project at university I have to create a High Score table in C++ with Visual Studio. Just to let you know this is my first year at university and also my first time ever learning C++....
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
| |