Comment

Peter Bengtsson

Shame it doesn't work without javascript though.

You could make it much simpler if you'd just write you input tag like this:

<input type="submit"
name="99"
value="Edit this"
onclick="this.value=this.name;this.name='idvalue'"
/>

...or I just don't understand your particular application problem.

Parent comment

Rich

I just got bit by this bug today, took me a while to figure out what was going on. I was using

Replies

Rich

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)

Daniel Danopia

Just pass 'this' and then you don't have to do an ID lookup.