diff options
author | Struan Donald <struan@exo.org.uk> | 2011-08-03 12:05:42 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-08-03 12:05:42 +0100 |
commit | 83666c88b4df6e30f1e292d06f475fbf5ea38faf (patch) | |
tree | 5e566800a9b51da66a282473071d6e40a1517b95 /web/js/fixmystreet.js | |
parent | 731c7b85766598ebf94a8498589ece048e7c2006 (diff) |
rejig data structure so we can sort the extra fields
Diffstat (limited to 'web/js/fixmystreet.js')
-rw-r--r-- | web/js/fixmystreet.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js index 22cd1c64f..ad3ff7c4d 100644 --- a/web/js/fixmystreet.js +++ b/web/js/fixmystreet.js @@ -61,11 +61,13 @@ $(function(){ if ( category_extras ) { $('#category_meta').empty(); if ( category_extras[this.options[ this.selectedIndex ].text] ) { - extras = category_extras[this.options[ this.selectedIndex ].text]; - for ( i in extras ) { - meta = extras[i]; + fields = category_extras[this.options[ this.selectedIndex ].text]; + $('<p>Additional information</p>').appendTo('#category_meta'); + fields.sort( function(a,b) { return a.order - b.order } ); + for ( i in fields) { + meta = fields[i]; field = '<div class="form-field">'; - field += '<label for="form_' + meta.code + '">' + meta.description + '</label>'; + field += '<label for="form_' + meta.code + '">' + meta.description + ':</label>'; field += '<input type="text" value="" name="' + meta.code + '" id="form_' + meta.code + '">'; field += '</div>'; $('<p>' + field + '</p>').appendTo('#category_meta'); |