Answers.Body: <p>The select2 is indeed complicated but you don't need to go there. The underlying select element is still there (just hidden) and still fires regular "change" events and you can still get it's value using the ordinary <code>$(element).val()</code> jQuery.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-27T14:49:04.787Z
Answers.LastActivityDate: 2015-07-27T14:49:04.787Z
Answers.UserDisplayName: Coleman
Body: <p>I have developed a site for a client that uses a profile to capture address and contact information for event registrations using CiviEvent. One of the fields on the registration form is a 'Country' field. There is a requirement from the client to fill in another form field with a default value based upon the Country selected. I have done similar things with jQuery in relation to other fields on the form, but the country field widget is quite complicated and I can't quite figure out how to target the user's selecting a country and get the country value with jQuery. I am sure there must be some code in CiviCRM that does this, in order to display the correct set of state/province fields based upon the country selection. But I have not been able to locate such code. Can anyone give me any pointers in terms of where I can find the CiviCRM code that does this, or sample JS/jQuery code that will detect the country field selection on a profile form? Note that this is on CiviCRM 4.6.2.</p>
  
  <p>Many thanks,
  -Ian</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-21T12:48:20.787Z
Comments.Text: it is not working when select element is hidden
Comments.UserDisplayName: Elena Kaminsky
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-21T15:46:19.623Z
Comments.Text: Hi @ElenaKaminsky: StackExchange uses a Question and Answer format, rather than a forum thread format. Please feel free to post a new question explaining your issue, with a link to other questions like this one if they provide some context. When you post your question, try to include more information about what you are trying to achieve, how you are going about that, what is not working (especially error text), and what you have tried so far to solve the problem.
Comments.UserDisplayName: Joe Murray
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-21T18:55:43.367Z
Comments.Text: This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](http://civicrm.stackexchange.com/questions/ask). You can also [add a bounty](http://civicrm.stackexchange.com/help/privileges/set-bounties) to draw more attention to this question once you have enough [reputation](http://civicrm.stackexchange.com/help/whats-reputation). - [From Review](/review/low-quality-posts/3415)
Comments.UserDisplayName: petednz - fuzion
Tags: <profile>
Title: Capture country field selection with JS/jQuery
ThreadText: # Capture country field selection with JS/jQuery
  
  (Asked by: username_0 on 2015-07-27)
  
  I have developed a site for a client that uses a profile to capture address and contact information for event registrations using CiviEvent. One of the fields on the registration form is a 'Country' field. There is a requirement from the client to fill in another form field with a default value based upon the Country selected. I have done similar things with jQuery in relation to other fields on the form, but the country field widget is quite complicated and I can't quite figure out how to target the user's selecting a country and get the country value with jQuery. I am sure there must be some code in CiviCRM that does this, in order to display the correct set of state/province fields based upon the country selection. But I have not been able to locate such code. Can anyone give me any pointers in terms of where I can find the CiviCRM code that does this, or sample JS/jQuery code that will detect the country field selection on a profile form? Note that this is on CiviCRM 4.6.2.
  
  Many thanks,
  -Ian
  
  **Tags:** profile
  
  > **Comments:**
  > **username_1**: it is not working when select element is hidden  
  > **username_2**: Hi @username_1: StackExchange uses a Question and Answer format, rather than a forum thread format. Please feel free to post a new question explaining your issue, with a link to other questions like this one if they provide some context. When you post your question, try to include more information about what you are trying to achieve, how you are going about that, what is not working (especially error text), and what you have tried so far to solve the problem.  
  > **username_3**: This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](http://civicrm.stackexchange.com/questions/ask). You can also [add a bounty](http://civicrm.stackexchange.com/help/privileges/set-bounties) to draw more attention to this question once you have enough [reputation](http://civicrm.stackexchange.com/help/whats-reputation). - [From Review](/review/low-quality-posts/3415)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_4 on 2015-07-27. Score: 2
  
  The select2 is indeed complicated but you don't need to go there. The underlying select element is still there (just hidden) and still fires regular "change" events and you can still get it's value using the ordinary `$(element).val()` jQuery.
  
  
  ---
  
  