0

I want to have a form which has a simple 2 step process:

(If a person on has one school assigned to them then skip straight to step 2)

Step 1 - Select a school from a drop-down list

Step 2 - Enter the required data from a data-entry form. Certain fields are disabled based on which school was selected.

I have had a look at the various methods for creating 'wizards' and at using partial Views. What is the best way to handle this? I was wondering if using AJAX is worthwhile considering or just having a two step process in the form.

James :-)

James Culshaw
  • 1,047
  • 8
  • 19
  • In your above case, based on the school selected, you can disable/enable controls using javascript or jQuery. $('.someElement').attr('disabled', ''); for disabling the control http://jquery-howto.blogspot.com/2008/12/how-to-disableenable-element-with.html – Narendra V Sep 20 '11 at 11:18
  • The data about what fields are to be disabled needs to be retrieved as it is not available in the page anywhere. – James Culshaw Sep 20 '11 at 14:37

1 Answers1

2

You should absolutely do this via ajax so your options are either

  1. use small partial views. your view logic determines what to disable/enable

  2. (probably easier and more lightweight) use json to get a list of property names to disable.Then you can simply disable them via jQuery ideally by iterating through each item with the .each() call. See: looping through JSON array in a jQuery list for a use of the each call. got jQuery getJson, see: http://api.jquery.com/jQuery.getJSON/

so: 1. getJson to get the results from a controller 2. enumerate using .each() and set the property

 $("#" + yourFieldName).attr("disabled","disabled");
Community
  • 1
  • 1
Adam Tuliper
  • 29,982
  • 4
  • 53
  • 71