473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Calculate score by getting user inputs in the Form and display the results. (ASP)

5
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.
Nov 21 '07 #1
4 2336
shweta123
692 Expert 512MB
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

Expand|Select|Wrap|Line Numbers
  1. <%
  2.   Dim Age
  3.   Dim Noofyears
  4.   Dim points 
  5.  
  6.   Age = Request.Form("Age")
  7.   Noofyears = Request.Form("Noofyears")
  8.  
  9.  If Age  = 15 then
  10.     points = 5
  11.  else if Age >15 and Age <31 then
  12.     points = 10
  13.  else if  Age >31 then
  14.    points = 20
  15.  else if Noofyears =2 then
  16.    points = 5
  17.   else if Noofyears >2 and Noofyears <5  then
  18.    points = 10
  19.  else if Noofyears >4 then
  20.    points = 30
  21.  else if Age =31 and Noofyears =3 then
  22.    points = 30
  23.  end if
  24.  
  25.  '''''Calculate Result 
  26. If points < 20  
  27.     Result = Bad
  28. If points> 20 and points< 31
  29.    Result =Avarage
  30. If points >31
  31.   Result =Good
  32.  
  33. '''''''Now store the result into db
  34.  Dim sql
  35.  Dim con
  36.  con= Server.CreateObject("Adodb.Connection")
  37.  con.connectionstring ="....."
  38.  con.open
  39.  sql = "Insert into tablename score ,result values(points, result)"
  40.  con.execute(sql)
  41.  con.close
  42. %>
  43.  
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.
Nov 21 '07 #2
gaya12
5
Thanks.

storeResults.asp

Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <html>
  3. <head>
  4. <title>Result</title>
  5. </head>
  6.  
  7. <body>
  8. <%
  9. Dim fbName, fbNic, fbAge, fbNoofyears, fbPoints, fbResult
  10.  
  11. fbName = Request.Form("textname")
  12. fbNic = Request.Form("textnic")
  13. fbAge = Request.Form("textage")
  14. fbNoofyears = Request.Form("textEYrs")
  15.  
  16.  
  17.  If fbAge  = 15 then
  18.     fbPoints = 5
  19.  else if fbAge > 15 and fbAge < 31 then
  20.     fbPoints = 10
  21.  else if  fbAge > 31 then
  22.    fbPoints = 20
  23.  
  24.  if fbNoofyears =2 then
  25.    fbPoints = 5
  26.  else if fbNoofyears > 2 and fbNoofyears <4 then
  27.    fbPoints = 5
  28.  else if fbNoofyears >= 4 then
  29.    fbPoints = 30
  30.  end if
  31.  end if
  32.  end if
  33.  end if
  34.  end if
  35.  end if
  36.  '''''Calculate Result 
  37. If fbPoints < 20 Then  
  38.     fbResult = Bad
  39.     Response.write("Bad")
  40. else If fbPoints > 19 and fbPoints < 31 Then
  41.    fbResult =Avarage
  42.    Response.write("Average")
  43. else If fbPoints > 31 Then
  44.   fbResult =Good
  45.   Response.write("Good")
  46.   end if
  47.   end if
  48.   end if
  49.  
  50.  Dim sql
  51.  Dim cn
  52.  
  53. set cn=server.CreateObject("ADODB.Connection")
  54. path=server.MapPath(".")
  55. cn.open "Driver=Microsoft Access Driver (*.mdb);DBQ="&path&"/admincp/dbase/newdata.mdb"
  56.  
  57. sql = "insert into score (Name, Nic, Age, NoOfYears, Points, Result) values ('" & _
  58.     fbName & "', '" & fbNic & "', '" & fbAge & "', '" & fbNoofyears & "', '" & fbPoints & "', '" & fbResult & "')"
  59.  
  60.  
  61. cn.execute(sql)
  62. cn.close
  63. %>
  64.  
  65. </body>
  66. </html>
  67.  
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.
Nov 23 '07 #3
shweta123
692 Expert 512MB
Hi ,

If you want to make the addition of all the points then modify the code in the If conditions like this
Expand|Select|Wrap|Line Numbers
  1.  
  2.  If fbAge  = 15 then
  3.     fbPoints =    fbPoints + 5
  4. end 
  5.  
  6. if fbAge > 15 and fbAge < 31 then
  7.     fbPoints =    fbPoints + 10
  8. end if
  9.  
  10. if  fbAge > 31 then
  11.    fbPoints =    fbPoints+20
  12. end if
  13.  
  14. if fbNoofyears =2 then
  15.    fbPoints =    fbPoints+5
  16. end if
  17.  
  18. if fbNoofyears > 2 and fbNoofyears <4 then
  19.    fbPoints =    fbPoints+ 5
  20. end if
  21.  
  22. if fbNoofyears >= 4 then
  23.    fbPoints =    fbPoints +30
  24. end if
After calculating the Points , please check what the value for Result is coming before inseting into the database.


Thanks.

storeResults.asp

Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <html>
  3. <head>
  4. <title>Result</title>
  5. </head>
  6.  
  7. <body>
  8. <%
  9. Dim fbName, fbNic, fbAge, fbNoofyears, fbPoints, fbResult
  10.  
  11. fbName = Request.Form("textname")
  12. fbNic = Request.Form("textnic")
  13. fbAge = Request.Form("textage")
  14. fbNoofyears = Request.Form("textEYrs")
  15.  
  16.  
  17.  If fbAge  = 15 then
  18.     fbPoints = 5
  19.  else if fbAge > 15 and fbAge < 31 then
  20.     fbPoints = 10
  21.  else if  fbAge > 31 then
  22.    fbPoints = 20
  23.  
  24.  if fbNoofyears =2 then
  25.    fbPoints = 5
  26.  else if fbNoofyears > 2 and fbNoofyears <4 then
  27.    fbPoints = 5
  28.  else if fbNoofyears >= 4 then
  29.    fbPoints = 30
  30.  end if
  31.  end if
  32.  end if
  33.  end if
  34.  end if
  35.  end if
  36.  '''''Calculate Result 
  37. If fbPoints < 20 Then  
  38.     fbResult = Bad
  39.     Response.write("Bad")
  40. else If fbPoints > 19 and fbPoints < 31 Then
  41.    fbResult =Avarage
  42.    Response.write("Average")
  43. else If fbPoints > 31 Then
  44.   fbResult =Good
  45.   Response.write("Good")
  46.   end if
  47.   end if
  48.   end if
  49.  
  50.  Dim sql
  51.  Dim cn
  52.  
  53. set cn=server.CreateObject("ADODB.Connection")
  54. path=server.MapPath(".")
  55. cn.open "Driver=Microsoft Access Driver (*.mdb);DBQ="&path&"/admincp/dbase/newdata.mdb"
  56.  
  57. sql = "insert into score (Name, Nic, Age, NoOfYears, Points, Result) values ('" & _
  58.     fbName & "', '" & fbNic & "', '" & fbAge & "', '" & fbNoofyears & "', '" & fbPoints & "', '" & fbResult & "')"
  59.  
  60.  
  61. cn.execute(sql)
  62. cn.close
  63. %>
  64.  
  65. </body>
  66. </html>
  67.  
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.
Nov 23 '07 #4
shweta123
692 Expert 512MB
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.
Nov 23 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
53
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...
11
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...
6
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...
4
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...
1
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...
7
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...
1
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...
3
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++....
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
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...
0
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...
0
tracyyun
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...
0
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...

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.