if you don't need to be specific with keys, let the browser/server figure out what keys to use. just like in PHP, you can append an array without knowing the last key.

Code:
<input type="hidden" name="items[]" value="whatever" />
using 5 of these should produce the keys 0 through 4.

if this solution doesn't work for you, then you might be able to apply some logic like, if $key is above $deleterow, then $key is equal to $key minus 1? but, I don't see too many situations where the above wouldn't work.