Cleaned and generalized code

For matching IDs according to WP encoding; fixed jQuery use of val()