|
|||||||
| ASP Discussion and technical support for using and deploying Active Server Pages. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How To Add Between two values
hello im a student.. i have a problem.. i want to add the values between "peruntukan" and "ptambahan"
below is my code: 1.new1.asp ( this one is a form for user to key in thier amount of budget) <html> <head> <title>SISTEM VOT BARU</title> </head> <script language = JavaScript> function verify() { document.returnValue = true; //check for blanks if (document.myForm.novot.value == "") { alert (" Sila masukkan No Vot!"); document.returnValue = false; } if (document.myForm.tahun.value == "") { alert (" Sila masukkan Tahun!"); document.returnValue = false; } if (document.myForm.peruntukan.value == "") { alert (" Sila masukkan Peruntukan Tahunan!"); document.returnValue = false; } } </script> <BODY BGCOLOR="#000000"> <CENTER> <IMG SRC="banner.jpg"> </cENTER> <BR> <BR> <BR> <BR> <BR> <BR> <font face="Verdana, Tahoma"> <FORM NAME="myForm" method="post" ACTION ="viewperuntukan1.asp" onSubmit="verify(); return document.returnValue"> <TABLE BORDER="1" CELLPADDING="1" CELLSPACING="0" ALIGN="CENTER" VALIGN="TOP" WIDTH="95%"><TR><TD BGCOLOR="black"> <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" WIDTH="100%"> <TR ALIGN="LEFT"> <TD BGCOLOR="99CCFF" width=25%><font size="2" face="Verdana, Tahoma"><b>No Vot :<b></TD> <TD BGCOLOR="99CCFF"><font size="2" face="Verdana, Tahoma"> <INPUT TYPE= "TEXT" name="novot" MAXLENGTH="32" SIZE="20"> </TD> </TR> <TR ALIGN="LEFT"> <TD BGCOLOR="99CCFF" width=25%><font size="2" face="Verdana, Tahoma"><b>Tahun :<b></TD> <TD BGCOLOR="99CCFF"><font size="2" face="Verdana, Tahoma"> <INPUT TYPE= "TEXT" name="tahun" MAXLENGTH="32" SIZE="5"> </TD> </TR> <TR ALIGN="LEFT"> <TD BGCOLOR="99CCFF" width=25%><font size="2" face="Verdana, Tahoma"><b>Peruntukan Seperti Di Dalam Anggaran Tahunan ( RM ) :<b></TD> <TD BGCOLOR="99CCFF"><font size="2" face="Verdana, Tahoma"> <INPUT TYPE= "TEXT" name="peruntukan" MAXLENGTH="32" SIZE="20"> </TD> </TR> <TR ALIGN="LEFT"> <TD BGCOLOR="99CCFF" width=25%><font size="2" face="Verdana, Tahoma"><b>Peruntukan Seperti Di Dalam Anggaran Tambahan ( RM ) :<b></TD> <TD BGCOLOR="99CCFF"><font size="2" face="Verdana, Tahoma"> <INPUT TYPE= "TEXT" name="ptambahan" MAXLENGTH="32" SIZE="20"> </TD> </TR> <TR ALIGN="LEFT"> <TD BGCOLOR="99CCFF" width=25%><font size="2" face="Verdana, Tahoma"></TD> <TD BGCOLOR="99CCFF"><font size="2" face="Verdana, Tahoma"> <P ALIGN=CENTER> <B> <INPUT TYPE="SUBMIT" VALUE="SUBMIT" NAME="SUBMIT"> <INPUT TYPE="RESET" VALUE="BATAL" NAME="RESET"> </B> </TD> </TR> </TABLE></TR></TD></TABLE> </FORM> </FONT> <BR> <BR> <BR> <BR> <BR> <FONT FACE="Verdana, Tahoma" SIZE="-2" COLOR="white"> <br> <CENTER>Copyright Reserved 2006</a> </CENTER> </FONT> </FONT> </BODY> </HTML> the 2nd code : viewperuntukan1.asp ( this code is to show the correct amount after the value is added ) <% @Language="Javascript" %> <% var dsn="dsn=VS"; var Conn= Server.CreateObject("ADODB.Connection"); Conn.Open(dsn); var no_vot = Request.Form("novot"); var thn = Request.Form("tahun"); var peruntukanthnn = Request.Form("peruntukan"); var tmbh = Request.Form("ptambahan"); var sql = "Insert into KE (NOVOT, TAHUN, PERUNTUKAN, ANGGARANT) VALUES ('"+no_vot+"','"+thn+"','"+peruntukanthnn+"', '"+tmbh+"');" Conn.Execute(sql); Conn.Close(); Conn=null; %> <HTML> <HEAD> <TITLE>JUMLAH PERUNTUKAN TAHUNAN</TITLE> </HEAD> <link rel="stylesheet" type="text/css" href="images181/blue.css"> <BODY BGCOLOR="#000000"> <CENTER> <IMG SRC="banner.jpg"> </cENTER> <BR> <BR> <BR> <BR> <BR> <BR> <FONT face="Verdana,Tahoma" COLOR="white"> <CENTER> <P>Peruntukan bagi Tahun <%=Request.Form("tahun") %> ialah RM <%=Request.Form("peruntukan") %> + <%=Request.Form("ptambahan") %> </P> </CENTER> </FONT> <FONT face="Verdana,Tahoma" SIZE="3"> <ALIGN="RIGHT"> <BR> <BR> <P> <A HREF="addnew1.asp">seterusnya>>>></A> </P> </ALIGN> </FONT> <BR> <BR> <BR> <FONT FACE="Verdana, Tahoma" SIZE="-2" COLOR="white"> <br> <CENTER>Copyright Reserved 2006</a> </CENTER> </FONT> </BODY> </HTML> But the problem is i dont know how to add this number.. please help me.. :cry: then there was an error in database( microsoft access) .. i dont know what to do.. help me.. :cry: than how i want to store this total value ( after add this two value ) in database ( microsoft access).. ?? i really appreciate if someone can help me.. |
|
#2
|
|||
|
|||
|
Quote:
var peruntukanthnn = Request.Form("peruntukan"); var tmbh = Request.Form("ptambahan"); var total = peruntukanthnn + tmbh Then to store it in the database you either have to create a new field to accommodate it, or you have to insert the total into one of your other fields
|
|
#3
|
|||
|
|||
|
thank you.. its mean that i have to create new column in my table in database right? but how to store it? how was the coding? is that the same like the above code?
|
|
#4
|
|||
|
|||
|
Well I suggest if you want to make changes to your tables download the database onto your local machine and open it in MS Access, add the column, then upload it back to the website
|
|
#5
|
|||
|
|||
|
thanks.. can i do like this? this is my new code.. i hope u can help me..
the 2nd code : viewperuntukan1.asp ( this code is to show the correct amount after the value is added ) <% @Language="Javascript" %> <% var dsn="dsn=VS"; var Conn= Server.CreateObject("ADODB.Connection"); Conn.Open(dsn); var no_vot = Request.Form("novot"); var thn = Request.Form("tahun"); var peruntukanthnn = Request.Form("peruntukan"); var tmbh = Request.Form("ptambahan"); var total = peruntukanthnn+tmbh; var sql = "Insert into KE (NOVOT, TAHUN, PERUNTUKAN, ANGGARANT, TOTAL) VALUES ('"+no_vot+"','"+thn+"','"+peruntukanthnn+"', '"+tmbh+"', '"+total+"');" Conn.Execute(sql); Conn.Close(); Conn=null; %> <HTML> <HEAD> <TITLE>JUMLAH PERUNTUKAN TAHUNAN</TITLE> </HEAD> <link rel="stylesheet" type="text/css" href="images181/blue.css"> <BODY BGCOLOR="#000000"> <CENTER> <IMG SRC="banner.jpg"> </cENTER> <BR> <BR> <BR> <BR> <BR> <BR> <FONT face="Verdana,Tahoma" COLOR="white"> <CENTER> <P>Peruntukan bagi Tahun <%=Request.Form("tahun") %> ialah RM <%=Request.Form("peruntukan") %> + <%=Request.Form("ptambahan") %> </P> </CENTER> </FONT> <FONT face="Verdana,Tahoma" SIZE="3"> <ALIGN="RIGHT"> <BR> <BR> <P> <A HREF="addnew1.asp">seterusnya>>>></A> </P> </ALIGN> </FONT> <BR> <BR> <BR> <FONT FACE="Verdana, Tahoma" SIZE="-2" COLOR="white"> <br> <CENTER>Copyright Reserved 2006</a> </CENTER> </FONT> </BODY> </HTML> please help.... |
|
#6
|
|||
|
|||
|
i had do what u had suggestion.. but i had face a problem....
Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression '2000',20002000''. /SYSTEM VOT/viewperuntukan1.asp, line 21 i had try to solve it but still having a same problem... help me.. |
|
#7
|
|||
|
|||
|
i had correct the mistakes but now i had face this problem... before this i had face the same problem too...i dont know why.. i had re-check and re-write but the problem is still at the same place.. why? i really dont understand..
Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [Microsoft][ODBC Microsoft Access Driver] The INSERT INTO statement contains the following unknown field name: 'ANGGARANT'. Make sure you have typed the name correctly, and try the operation again. /SYSTEM VOT/viewperuntukan1.asp, line 21 before this i use field name ( ANNGGARANT) as ( TAMBAHAN) but still face the same problem.. i really hope that someone can help me... please.... |
|
#8
|
|||
|
|||
|
helo.. after re-check and re-write.. i had face this problem... please help me
Error Type: Microsoft JScript runtime (0x800A01B6) Object doesn't support this property or method /SYSTEM VOT/viewperuntukan1.asp, line 16 |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|