I have a form as shown in PHP where user can build a quiz by adding question and possible answers. User can add multiple answers by clicking Add Answer which just on more empty row .When Save is clicked I insert/edit question and answers.I am thinking whats best way to do this when question is edited?
1 . Delete all answers and Insert again. That way I dont have to check if any answer was modified or a new answer was added on client side.
2 . Add extra element title to textbox which will have answer id while a new question will have id blank. When user clicks save I will update all answers with id not blank . Insert all those with no id .
I am thinking to implement it as option 2 but is there any other better way ?

If you want to do this you can probably put information in your rel tag
so if the item was modified you can put rel=”modified” and if it is a new item you can put rel=”new” and if the item is deleted you can put rel=”deleted” (and of course hide the deleted div instead of removing it).
Once save is clicked you can build the proper query by going through the elements and checking their rel attribute.