PROJECT: To add a delete button to the bottom of div and call an delete functions to delete record by current querystring("q").
PROBLEM: No value is getting passed through to the sql statement to delete anything.
CURRENT STATUS: I have a dropdown box that onchange calls this function
I have placed the "txthintb" div under my dropdown. So now when people use the dropdown the div fills up with info. Works perfect. Here is my getcustomerb.asp page:
But what I am trying to do is add a delete function to the whole thing. So I created the functions wich works:
and this functions calls my delete.asp page:
this is where the problems comes in, I have tried to place a button with an onclick event to call the delCustomerd() functions. I tried with this following code:
But with no luck. It goes through but nothing get deleted. I have tried to replace the buttons onclick event with just a simple alert(bid) to have an alert show me what is getting passed through, but it comes up undefined. I have pretty much tried everything and am now at the mercy of the forum. Any help or direction would be greatly appreciated.
PROBLEM: No value is getting passed through to the sql statement to delete anything.
CURRENT STATUS: I have a dropdown box that onchange calls this function
Code:
var xmlHttp
function showCustomerb(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getcustomerb.asp"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedb
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChangedb()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHintb").innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObjectb()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
Code:
<%
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/database/databasename.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT COMPANY, ADDRESS, CITY, STATE, ZIP FROM BILL WHERE BILLID = '" & Request.QueryString("q") &"'"
rs.Open sql, conn
response.write("<table>")
do until rs.EOF
for each x in rs.Fields
response.write("<tr><td style=""FONT-SIZE: 10px; padding-left: 60px; FONT-FAMILY: Tahoma"">" & x.value & "</td></tr>")
next
rs.MoveNext
loop
response.write("</table>")
%>
But what I am trying to do is add a delete function to the whole thing. So I created the functions wich works:
Code:
var xmlHttp
function delCustomerd(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="delete.asp"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedb
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChangedb()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHintb").innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObjectb()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
Code:
<%
Set ObjCon = Server.CreateObject("ADODB.Connection")
ObjCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/database/databasename.mdb")
strSQL = "Delete FROM BILL WHERE BILLID=' & Request.QueryString(""q"") &'"
objcon.Execute strSQL, , adCmdText
ObjCon.Close
Set ObjCon = NOTHING
%>
this is where the problems comes in, I have tried to place a button with an onclick event to call the delCustomerd() functions. I tried with this following code:
Code:
<%
Dim bid
bid = Request.QueryString("q")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/_database/BuckleyAssc.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT COMPANY, ADDRESS, CITY, STATE, ZIP FROM BILL WHERE BILLID = '" & Request.QueryString("q") &"'"
rs.Open sql, conn
response.write("<table>")
do until rs.EOF
for each x in rs.Fields
response.write("<tr><td style=""FONT-SIZE: 10px; padding-left: 60px; FONT-FAMILY: Tahoma"">" & x.value & "</td></tr>")
next
rs.MoveNext
loop
response.write("<tr><td style=""FONT-SIZE: 10px; padding-left: 60px; FONT-FAMILY: Tahoma""><input name="""" type=""button"" onClick=""delCustomerd(bid)"" value=""Delete"" /></td></tr>")
response.write("</table>")
%>