Click to See Complete Forum and Search --> : JavaScript button to open database??
Portmoon
02-13-2003, 06:38 PM
Hi!
I just wanted to know how to create a button in JavaScript that will execute 2 functions in JavaScript. The button when clicked should verify (or reject) a password entered by the user (i.e Check it against a password previously stored in the database). If verified then the button should open MS Access giving the database administrator access to the database for adding, editing deleting records etc..
Any help would be much appreciated!!
Thanks alot,
Roddy
JavaScript can not connect to a database. You will need a server side language such as PHP, Perl, or ASP to do this.
khalidali63
02-13-2003, 07:48 PM
JavaScript without then help of hard core prgramming languages (C/C++,Java) is will not be able to do this task.( you can not access system resources with JavaScript)
cheers
Khalid
Portmoon
02-14-2003, 10:18 AM
Thanks for replying!!
Does this mean that it is not possible to transpose this VBScript to Javascript to enable client side scripting.
Does the following code 'have' to be executed on a server in order for it to access the database???
Thanks
<%
Dim accessDb, myDSN, dbConnection, dbQuery, recordSet
accessDb = "myDatabase.mdb"
myDSN = "Driver={Microsoft Access Driver (*.mdb)};
myDSN = myDSN & "DBQ=" & server.mappath(accessDb)
Set dbConnection = Server.CreateObject("ADODB.Connection")
Set rsRecordSet = Server.CreateObject("ADODB.RecordSet")
dbQuery = "SELECT * FROM myDatabase ORDER BY name "
Set recordSet = dbConnection.Execute(dbQuery)
if not((rsRecordSet.EOF) OR (rsRecordSet.BOF)) then
Response.Write("<h1>no records found in the database<h1>")
else
rsRecordSet.MoveFirst
while not(rsRecordSet.EOF){
Response.Write(RecordSet("name") &_
"(" & recordSet("number") &
")<br>")
rsRecordSet.MoveNext
loop
end if
rsRecordSet.Close
dbConnection.Close
Originally posted by Portmoon
Does the following code 'have' to be executed on a server in order for it to access the database???Yes, the database query has to be executed server side. You can, however, move the values into javascirpt something like the following
<script language="javascript" type="text/javascript">
var test = "<%= aspvar %>"
</script>
NOTE: I don't know any ASP, so the above was just a guess on syntax, but I wanted to show you it is possible. ;)
Portmoon
02-15-2003, 08:34 AM
Thanks again 'Pyro' for your advice, this clarifies a few doubts I had regarding JavaScript!
Cheers,
:)