Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating an oracle database from a javascript function

Status
Not open for further replies.

Vic88

MIS
May 29, 2000
76
JM
Hi All

I am creating the front end of a database. I want to be able run a command that update a table when the user ckick a button.


The format would be like

<html>
<head>
<script type="text/javascript">
function Update_database()
{
---Code to update database goes here

document.all("myButton").focus()
}
</script>
</head>

<body>
<form>
<input type="button" value="Click me!" name="myButton" onClick="update_database()" />
</form>
</body>

</html>


I am having trouble with the code that updates the database. In fact, I don't even know if it can work this way as I am new to Javascript.

Any help will be highly appreciated.


Vic88
 
You'll have to pass the "action" of your button to server-side script that will work with Oracle. It can't be done directly from javascript. In fact, you don't even need javascript to do this - just use a "Submit" button to call the script.

There's always a better way. The fun is trying to find it!
 
I was able to do something like this using PHP/MYSQL/Javascript.

You will have to do the following.

document.write("connection string to db");
document.write("syntax for sql statment");
document.write("syntax to execute sql statement");
document.write("close connection string");

It can be tricky because of all the quotation marks used inside the document.write function..

Mike V.
 
Mike,

PHP is s server-side script and can connect directly to the database. There was no need to use javascript to do it. The javascript you created was actually passing the values to PHP, then PHP took over. It worked, but it was an unnecessary step.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top