Set amount of fields on an existing content type One of our website requirements is to have a content type that lets you decide on the total amount of form fields on the fly. 

For example, if I specify a number 10, then it ought to generate the form fields consecutively; the text area and the checkbox form fields are created 10 times.

Essentially, to break it programmatically, it will create:

for(i = 0; i &lt; 10; i++) {
  echo "&lt;input type = 'textarea'&gt;&lt;/input&gt;";
  echo "&lt;select&gt;&lt;option&gt;1&lt;/option&gt;&lt;option&gt;2&lt;/option&gt;&lt;/select&gt;";
} 


This is pretty straightforward if I was dabbling with simple PHP files, but with Drupal 7's fields it is posing a bigger challenge than what it ought to be. I have tried exploring modules that let you create content types on the fly and considered creating a custom content type programmatically which seems like another challenge altogether.

I am curious if anybody has an alternative for this, and has dabbled with this challenge before.
If I understand you correctly, you're trying to change the cardinality of a field based on user input. You can do this by using field_update_field():

$field_name = 'field_bar';
$field = field_info_field($field_name);

$field['cardinality'] = 10;  // Change to number you want

// field_update_field() throws an exception on failure
try {
  field_update_field($field);
}
catch (Exception $e) {
  drupal_set_message(t('Could not update field.'), 'error');
}


As you can see, cardinality is actually a per-field setting: if you wanted to do this on a per-instance basis (so, separate cardinality for the field for each content type/bundle), you actually need to create an entirely new field for each bundle.

This would likely cause a number of issues, particularly if you wanted to do things like display the values in a view (each field would be handled separately, even though the only thing different is the name and the cardinality).

Instead, what I'd do is just set the cardinality of the field you want to be dynamic to "unlimited" (FIELD_CARDINALITY_UNLIMITED in code): out of the box you get a fancy widget that lets users add as many values as they'd like.