please help,
i have this form, its for adding some information to an mdb access
http://i41.tinypic.com/2gvvw4k.jpg
after user select car number, i put an onchange javascript event it will inform the user how much this car cost (gasoline/toll/parking/etc) that has been spent from 1st January 2011 until today, were the pass total cost under budget or not.
these the form asp code (this code worked):
Code:
<td class="ThRows Trans_Program_COP_3_TableText"><span id="Trans_Program_COP_3_No__Polisi_Kendaraan_label">Car No.</span></td>
<%
CellValue = ""
if isEmpty(QSRequestForm("add_fd2")) then
ItemValue = "" & Rs(2) & ""
else
ItemValue = QSRequestForm("add_fd2")
end if
CellValue = "<div id='qs_listmenu_div'><select name=""add_fd2"" onChange=""ceksaldo()"" ><option value="""""&QSCheckSelected("",ItemValue,"Selected")&">-- Select --</option>" & QSGenListBox(Connect_String," Select ref_mobil.`ID`, ref_mobil.`Nopol`, ref_mobil.`Status` From ref_mobil ref_mobil Where UCASE(ref_mobil.`Status`) = 'PROGRAM' ","Nopol","Nopol",ItemValue) & "</select></div>"
CellValue = " "
end if
Response.Write "<td class=" &CssClass& " align=Default ><span id=""Trans_Program_COP_3_No__Polisi_Kendaraan_value"""
Response.Write ">" &CellValue& "</span></td>"
%>
</tr>
and this is the javascript function on onchange event ( i put dynamically asp script on javascript)
Code:
<SCRIPT TYPE="text/javascript">
function ceksaldo(){
var cekdb = document.getElementById('No__Polisi_Kendaraan');
if(cekdb.value != ""){
<%
dim mTotBBM, mTotal, plafond
dim tahunini, tglini, tglskr, cekdb
tahunini = year(now())
tglini = cdate("1/1/"& tahunini)
tglskr = date()
cekdb = Request.QueryString()
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.MapPath(".\db\db.mdb"))
'start - this down code is not working
set rs = conn.execute("SELECT SUM(Reimburse_BBM_Rp) as TotBBM FROM db_CarOwnerProgram WHERE Nopol = '" & Request.Form("add_fd2") & "'" & " AND tanggal BETWEEN '" & <%=tanggalini%> &"' AND '" & <%=tglskr%> & "'" )
'end - this down code is not working
mTotBBM = rs("TotBBM")
rs.close
conn.close
%>
alert("Total cost this car from 1/1/<%=tahunini%> to <%=day(tglskr) & "/" & month(tglskr) & "/" & year(tglskr)%>\nRp.<%=FormatNumber(mTotBBM)%>");
}
}
</SCRIPT>
fields for additional info:
Reimburse_BBM_Rp = Currency type
Tanggal = Date format medium date (aa-bb-cccc) aa = day, bb = month, cccc = year
Nopol = Text type
so my problem are:
1. how do I transfer the cekdb.value from javascript variable to SQL where condition (Nopol) properly. shown in code i use request.form("add_fd2") -=> this code its not work, i've debug with alert javascript code, it's empty.
2. mind to help proper sql between date.
AND tanggal BETWEEN '" & <%=tanggalini%> &"' AND '" & <%=tglskr%> & "'"
thank you.