Answers.Body: <p>I just tried this on CiviCRM 4.6.18 and successfully passed the amount through using the field Name or id (inspect the field to find the name or id)
  In the case of my form I did this:
  <a href="http://example.org/civicrm/contribute/transact?reset=1&amp;id=2&amp;price_5=35" rel="nofollow">http://example.org/civicrm/contribute/transact?reset=1&amp;id=2&amp;price_5=35</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-29T04:24:00.080Z
Answers.Text: This is still working on civicrm 5.x.x
Answers.UserDisplayName: Luke Stewart
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-18T00:24:15.470Z
Answers.LastActivityDate: 2016-07-18T00:24:15.470Z
Answers.UserDisplayName: Yossi
Answers.Body: <p>If a javascript solution suits you:</p>
  
  <pre><code>var a = document.createElement('a');
  a.href = document.location;
  var amount = a.search.match(/amount=([0-9]+)/)[1];
  jQuery('#search input[name="q"]').val(amount);
  </code></pre>
  
  <ul>
  <li>Visit <a href="https://civicrm.stackexchange.com/questions/4899/pass-in-contribution-amount-via-url?amount=1234">this URL</a> -- current page + <code>?amount=1234</code></li>
  <li>Paste the above code in your browser console</li>
  <li>Observe that the StackExchange search box now contains the value from the current page's query params.</li>
  <li>Add a free-text amount input to your contribute form.</li>
  <li>Use equivalent approach to populate that value on your own site.</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T04:12:10.773Z
Answers.Text: [1](http://wiki.civicrm.org/confluence/display/CRMDOC/Update+custom+fields+in+contributions+and+events+by+passing+variables+in+a+URL), [2](https://forum.civicrm.org/index.php/topic,34966.msg148876.html#msg148876). The first two lines look weird, but they are just there to allow the third to easily steal the query param from the current URL.
Answers.UserDisplayName: Chris Burgess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T08:58:03.687Z
Answers.Text: Thanks for the solution .It would be great to have a CiviCRM generated form, ideally attached to the Contribution ID. The idea is to apply a payment using the CiviCRM payment processor to an existing contribution. I was hoping I could use an existing contribution form and pipe the contribution ID and amount in.
Answers.UserDisplayName: Adam
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T09:16:51.157Z
Answers.Text: The solution above is intended for that use case. If you need it in the page instead of via JS, you want `hook_buildform()` in a custom extension I think.
Answers.UserDisplayName: Chris Burgess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T10:16:58.267Z
Answers.Text: Thanks. Did you have an example to get started?
Answers.UserDisplayName: Adam
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T18:35:10.860Z
Answers.Text: The civi tracker module linked in the wiki article on [this comment](http://civicrm.stackexchange.com/questions/4899/how-can-i-pass-in-the-contribution-amount-via-url/4901#comment4218_4901) is an example with similar functionality if you join the dots.
Answers.UserDisplayName: Chris Burgess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-25T01:12:31.713Z
Answers.Text: Thanks @Chris-Burgess. Will take a look. The link text in your last commend appears to point to this same post?
Answers.UserDisplayName: Adam
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-25T02:14:24.387Z
Answers.Text: Yes, it's pointing to the comment with links 1, 2 above it, one of which is a reference to existing documentation on the CiviCRM Wiki.
Answers.UserDisplayName: Chris Burgess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-24T04:10:49.767Z
Answers.LastActivityDate: 2015-08-24T04:10:49.767Z
Answers.LastEditDate: 2017-04-13T12:53:13.017Z
Answers.UserDisplayName: Chris Burgess
Body: <p>Is there a quick way to pass in the contribution amount via URL on custom amounts?</p>
  
  <pre><code>http://example.org/civicrm/contribute/transact?reset=1&amp;id=2&amp;price=35
  </code></pre>
  
  <p>I'm not looking to use a price set, just a total amount. Ideally, I'd like to pay an existing contribution and bring up a form with the amount and contribution to pay against with a credit card.</p>
  
Tags: <contributions><price-sets>
Title: How can I pass in the contribution amount via URL?
ThreadText: # How can I pass in the contribution amount via URL?
  
  (Asked by: username_0 on 2015-08-24)
  
  Is there a quick way to pass in the contribution amount via URL on custom amounts?
  http://example.org/civicrm/contribute/transact?reset=1&id=2&price=35
  
  I'm not looking to use a price set, just a total amount. Ideally, I'd like to pay an existing contribution and bring up a form with the amount and contribution to pay against with a credit card.
  
  **Tags:** contributions, price-sets
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-07-18. Score: 4
  
  I just tried this on CiviCRM 4.6.18 and successfully passed the amount through using the field Name or id (inspect the field to find the name or id)
  In the case of my form I did this:
  <http://example.org/civicrm/contribute/transact?reset=1&id=2&price_5=35>
  
  > **Comments:**
  > **username_2**: This is still working on civicrm 5.x.x  
  
  ---
  
  ### Answer by username_3 on 2015-08-24. Score: 3
  
  If a javascript solution suits you:
  var a = document.createElement('a');
  a.href = document.location;
  var amount = a.search.match(/amount=([0-9]+)/)[1];
  jQuery('#search input[name="q"]').val(amount);
  
  
  Visit this URL -- current page + ?amount=1234
  Paste the above code in your browser console
  Observe that the StackExchange search box now contains the value from the current page's query params.
  Add a free-text amount input to your contribute form.
  Use equivalent approach to populate that value on your own site.
  
  > **Comments:**
  > **username_3**: [1](http://wiki.civicrm.org/confluence/display/CRMDOC/Update+custom+fields+in+contributions+and+events+by+passing+variables+in+a+URL), [2](https://forum.civicrm.org/index.php/topic,34966.msg148876.html#msg148876). The first two lines look weird, but they are just there to allow the third to easily steal the query param from the current URL.  
  > **username_0**: Thanks for the solution .It would be great to have a CiviCRM generated form, ideally attached to the Contribution ID. The idea is to apply a payment using the CiviCRM payment processor to an existing contribution. I was hoping I could use an existing contribution form and pipe the contribution ID and amount in.  
  > **username_3**: The solution above is intended for that use case. If you need it in the page instead of via JS, you want `hook_buildform()` in a custom extension I think.  
  > **username_0**: Thanks. Did you have an example to get started?  
  > **username_3**: The civi tracker module linked in the wiki article on [this comment](http://civicrm.stackexchange.com/questions/4899/how-can-i-pass-in-the-contribution-amount-via-url/4901#comment4218_4901) is an example with similar functionality if you join the dots.  
  > **username_0**: Thanks @Chris-Burgess. Will take a look. The link text in your last commend appears to point to this same post?  
  > **username_3**: Yes, it's pointing to the comment with links 1, 2 above it, one of which is a reference to existing documentation on the CiviCRM Wiki.  
  
  ---
  
  