I am not clear why you need javascript here. Inside the button click procedure for the save button, you can always check if records exist in the database based on on some input field. First check with some value (mostly the primary key value) if such a record exists in the database table and if it does update the record instead of inserting. I hope there is a primary key field in your table. If the record does not exist then go ahead and insert the record. All this can be done very well with one stored procedure which examines the input values and updates or inserts accordingly. There is no need to bring in javascript code here. Hope this helps.

Warm Regards,