I didn't want the user to see the name of the button suddenly change to a piece of code the moment it's clicked on. My solution involves a longer bit of javascript, but it's a one-time cost since every page that uses just links to a site-wide .js file, and the in-button portion is pretty simple. Plus it's completely transparent to the user.
I've made a slight change to it, in that the button HTML code is now:
Shame it doesn't work without javascript though.
You could make it much simpler if you'd just write you input tag like this:
...or I just don't understand your particular application problem.
Comment
I didn't want the user to see the name of the button suddenly change to a piece of code the moment it's clicked on. My solution involves a longer bit of javascript, but it's a one-time cost since every page that uses just links to a site-wide .js file, and the in-button portion is pretty simple. Plus it's completely transparent to the user.
I've made a slight change to it, in that the button HTML code is now:
<input type="submit" id="button_99_edit" name="submit" value="Edit Foo" onclick="submitAndRedirect(this.id, 'edit-99')"/>
(Replaced hard-coded ID with this.id)
Parent comment
Shame it doesn't work without javascript though. You could make it much simpler if you'd just write you input tag like this: ...or I just don't understand your particular application problem.
Replies
Just pass 'this' and then you don't have to do an ID lookup.