Elyse Ku Felts
Elyse Ku Felts

Reputation: 11

jQuery: On form submit, change form's style class

I'm working on a prototype in which there will be several short forms submitted on a page as a user works through transcribing and coding a dataset. I'd like for submitted items to change to a different css class (so that the user can visually see a list item as completed, but can still go back and resubmit if there's an error), but can't quite figure out how.

I admit to being a "plug and play" jQuery user, which is a large part of my problems. Any help is appreciated!

EDIT with some more information:

So a few caveats here are that I'm only working on UI, someone else is handling the backend. These forms are supposed to push the information into a database. Individuals will be assigned hundreds of sound files to transcribe. We'll be breaking them into sets of 100 which they will be able to work through in sub-sets of 10. At present, I have an ordered list set up in which all the sound files/calls to the database/etc. will be dumped. There is a jQuery paging function which shows only ten per 'quasi-page'.

For each individual list item, the user will click to listen to a file, then decide if it was understandable or not. If it was, they select "yes" and one form appears, if it wasn't, they select "no" and a different form appears.

With all that I'm not sure if the code is really necessary. I'll add it if it would help.

Upvotes: 1

Views: 2780

Answers (2)

yati sagade
yati sagade

Reputation: 1375

use the .addClass() method. http://api.jquery.com/addClass/

Upvotes: 1

Bojangles
Bojangles

Reputation: 101473

Forms have the .submit() method. Use it like this:

$('form').submit(function() {
    $(this).addClass('foo');
});

The form will, of course, only keep that class until the page is reloaded. You don't say whether you're using AJAX, or how much of your code you've written, so I can't say much more.

Upvotes: 1

Related Questions