Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 11th, 2011, 03:31 AM
mfj mfj is offline
Registered User
 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default help me on javascript variable value to asp var and SQL between date

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 = "&nbsp;"
    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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
using JavaScript var in C# ASP.net om_anshuman Javascript How-To 2 July 30th, 2008 01:53 PM
storing Javascript variable to ASP variable rupen Classic ASP Basics 5 April 10th, 2007 07:06 AM
assign javascript variable to asp variable manjunath_c_k Classic ASP Basics 1 September 14th, 2006 07:35 AM
passing js var to asp sql okl Javascript 1 March 11th, 2005 05:40 AM
passing js var to asp sql okl Classic ASP Databases 1 March 11th, 2005 05:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.