CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • TIP: Using jQuery to hide different amounts
Pages: [1]

Author Topic: TIP: Using jQuery to hide different amounts  (Read 1800 times)

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
TIP: Using jQuery to hide different amounts
June 22, 2011, 05:07:40 pm
You can use jQuery to hide certain contribution amounts, event registration levels, or membership pricings.

It's pretty easy to do, but the key is identifying the unique 'id' of the radio button of the item you wish to hide.

Use Firebug to click on the radio button and copy and paste the id number.   The ids are cryptic and will look something like:

Code: [Select]
CIVICRM_QFID_369_2

Then use some jQuery.  You can put this jQuery in one of three places.
  1. a unfiltered block that is visible on the page in question (Drupal only)
  2. in your site's theme files
  3. in a custom .tpl in a Custom Template Directory in CiviCRM

Here is an example of the jQuery code.

NOTE: there is no need to use drupal_add_js() or any other function.  This is just pure jQuery code.  Copy and paste, filling in the id of your field where indicated

This jQuery does 3 things:  Hides the radio button itself, hides the label, and hides the <br> tag immediately after the label.  So easy.
Code: [Select]
<script>
$("#YOUR_CIVICRM_QFID_999_9").hide();
$("label[for='YOUR_CIVICRM_QFID_999_9']").next('br').remove();
$("label[for='YOUR_CIVICRM_QFID_999_9']").hide();
</script>

If anyone has other ideas please comment on this thread or add examples on this page on the wiki at the bottom.
« Last Edit: June 22, 2011, 05:15:44 pm by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: TIP: Using jQuery to hide different amounts
June 23, 2011, 04:37:30 am
How to Customize CiviCRM Pages with jQuery
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: TIP: Using jQuery to hide different amounts
June 23, 2011, 12:37:20 pm
nice post with greater detail, I have posted my code snippet into your blog
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • TIP: Using jQuery to hide different amounts

This forum was archived on 2017-11-26.