User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,646 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,710 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

calculating values using onclick

Join Date: Mar 2008
Posts: 3
Reputation: HenryForbes is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
HenryForbes HenryForbes is offline Offline
Newbie Poster

Question calculating values using onclick

  #1  
Mar 1st, 2008
Help,
I have a web based form containg values typed in by the user. The first value is called noItems, which is outside the form. The form contains a persons name, the number of items,noSub, thay have submitted and their final grade. I need to use noItems and noSub to calulate their prcentage and store it in the grade column of the table. How do I use a command button to, when clicked, go through the data on the table and calculate the final grade(as a percentage for each row?
my code is below:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/conn_3_coast.asp" -->
<%
Dim rs_homework
Dim rs_homework_cmd
Dim rs_homework_numRows

Set rs_homework_cmd = Server.CreateObject ("ADODB.Command")
rs_homework_cmd.ActiveConnection = MM_conn_3_coast_STRING
rs_homework_cmd.CommandText = "SELECT DISTINCT tblStudent.Name, studentResults.enrolno FROM tblStudent INNER JOIN studentResults ON tblStudent.enrolno = studentResults.enrolno ORDER BY tblStudent.Name"
rs_homework_cmd.Prepared = true

Set rs_homework = rs_homework_cmd.Execute
rs_homework_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 25
Repeat1__index = 0
rs_homework_numRows = rs_homework_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function calcGrade(){


}
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>
</head>

<body>
<h1>Coast@JCC</h1>
<h1>Homework</h1>
<form id="form2" name="form2" method="post" action="">
<table width="293" border="1">
<tr>
<td width="175">Number of Homeworks this period</td>
<td width="102"><input type="text" name="noHomeworks" id="noHomeworks" /></td>
</tr>
</table>
</form>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="">
<table width="596" border="1">
<tr>
<td width="201">Name</td>
<td width="107">Enrolment Number</td>
<td width="131">Homeworks Submited</td>
<td width="129">Grade</td>
</tr>
<tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_homework.EOF))
%>
<td><%=(rs_homework.Fields.Item("Name").Value)%> </td>
<td><%=(rs_homework.Fields.Item("enrolno").Value)%> </td>
<td><input type="text" name="submitted" id="submitted" value="0"/></td>
<td><input type="text" name="hwkGrade" id="hwkGrade" value="0" /></td><tr></tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_homework.MoveNext()
Wend
%>
<td height="110"></tr>
</table>
</form>
<form id="form3" name="form3" method="post" action="">
<input name="Calculate" type="submit" id="Calculate" onclick="MM_callJS('calcGrade()')" value="Submit" />
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Page title goes here</p>
<p>&nbsp;</p>
<p>Page title goes here</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<%
rs_homework.Close()
Set rs_homework = Nothing
%>
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 6:25 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC