I'm completely stuck on this SQL problem

vage

2[H]4U
Joined
Jan 10, 2005
Messages
3,038
So heres my problem. I have this button on my web page that allows me to link related forms to the one that I am creating. It then adds the related forms number and title into a table nice and neat. That part works great, but now what I want to be able to do is add a delete button next to each related form incase someone puts the wrong one in on accident. How would I use the onClick even for the button to delete the record in that current row?
 
Are you using an onclick event to create the form in the first place? I'm either not understanding the problem or there is info missing, but I would think you could do an DELETE FROM query instead of an INSERT INTO?
 
The forms are already created and stored in a table in the database. When you are making a new one, however, you have an option to link previous ones to the new one. When you click on a button, it searches the table for the record you want to link, then inserts a new entry into a separate table with the linked forms number and title. The reason I do this is because many new forms can link to the same previous form, but shouldn't be related.

Once the form is in the new table, a new row appears in the html document to hold the information about that linked form. What I want is to have a button next to each linked form that will allow me to remove it from the row and the table in the database so that it is no longer linked.
 
Do you know the SQL it would take to delete the link between forms?
Do you know how to make the CGI params from a URL cause an action to occur?
Do you know how to build a URL and attach it to your button?

It sounds like you have all of this, what's the problem?
 
The problem is that I simply don't know how I can use SQL statements inside of the onClick so that I can delete the record.
 
That is becuase you can't do that as far as I know, and why would you want the client side to have access to your DB.
 
Thats what I figured. So how would I go about "passing" the record number that the user wants to delete so that I can do all the SQL server side?
 
Thats what I figured. So how would I go about "passing" the record number that the user wants to delete so that I can do all the SQL server side?

I assume you have a listing page and a delete page. If so, when displaying the records in the list page, append the ID of the record to the delete page URL e.g. delItem.php?id=2. Then do your processing from there on.

There are couple more things you should check before deleting, but focus on this first (e.g. does this record belong to the user?, does the record exist in the system?). The rest can come later.
 
Thanks that does work but now I seem to have run into another problem. It is actually trying to go to my delete page now, which doesn't have anything on it, its simply deleting the record from the database. Is there a way to get it to run this delete part, and immediately redirect back to the original page?
 
Thanks that does work but now I seem to have run into another problem. It is actually trying to go to my delete page now, which doesn't have anything on it, its simply deleting the record from the database. Is there a way to get it to run this delete part, and immediately redirect back to the original page?

Delete the record u mean and not the page?

Just do a redirect to the listing page. What programming language r u using?
 
This is why its so confusing, the product that I am working on has its own language called Simple Server Page. For the most part it works the same as ASP but is formatted a lot like javascript.

What I'm doing is using the onClick to call a javascript function that confirms if they want to delete the record. If they do, I use form.action to submit to my delete page passing the record I want to delete with it. But, all I want to do is delete the record and refresh the page I was currently on.
 
Does the record actually get deleted with the changes you've made? What's the form action targetted to?
 
The form action goes to 'RemoveRecord.ssp?ID=' + idNumber;

RemoveRecord.ssp simply has a DELETE sql statement in it and then a redirect back to the orignal page.
 
Back
Top