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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • pre-populate contribution pages with AMOUNT
Pages: [1]

Author Topic: pre-populate contribution pages with AMOUNT  (Read 1425 times)

alextronic

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 2
  • I do what I do
pre-populate contribution pages with AMOUNT
May 21, 2009, 07:50:24 am
Hi all,

We're using CiviCRM for our new site, and I'm modifying some stuff to get what we need. Might not be best practice, but I need to understand if there is something I should know about how does civicrm/contribute/transact work in order to understand the following:

I'm using this javascript code in my page.tpl.php template file, it's part of a function that runs when in a contribution page form, it receives the amount to prepopulate the form with as a GET variable in the URL:

Code: [Select]
if ( vars['amountOther'] ) { //GOT VARIABLE AFTER SLICING URL
document.Main.amount_other.value = parseInt ( vars['amountOther'] - 0 );
}

As you can see, I update the "Other Amount" field with the value in the GET variable, so that when I go to http://example.com/civicrm/contribute/transact?reset=1&id=6&amountOther=3750, the field is pre-populated with the amount of 3750 dollars...

...BUT, when I click on Contribute button, it sends me back to the form, saying "Contribution Amount is a required field". I must say I have suceeded in pre-populating the pledge radio buttons to "pledge on" if in the previous page the user has opted so, and the value of the radio button is sent perfectly.

How is the value of amount_other processed? Which might be the problem?

Thanks so much in advance!!

Alex

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: pre-populate contribution pages with AMOUNT
May 21, 2009, 09:15:21 am

you also need to set the POST variable for the amount_other_radio  radio button. i.e. amount['amount_other_radio'] = 1

the radio button is required as the QuickForm rule and hence u get that error

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

alextronic

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 2
  • I do what I do
Re: pre-populate contribution pages with AMOUNT
May 21, 2009, 01:12:31 pm
OK, I got it now. Thanks Lobo, that did the trick.
« Last Edit: May 21, 2009, 02:45:32 pm by alextronic »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • pre-populate contribution pages with AMOUNT

This forum was archived on 2017-11-26.