-
- // set selected values of select elements
- var selects = r.find('select');
- $this.filter('select').each(function(i) {
- selects[i].selectedIndex = this.selectedIndex;
+ }
+
+ // copy form values over
+ if (deep) {
+ var inputs = r.add(r.find('*')).filter('select,input[@type=checkbox]');
+ $this.filter('select,input[@type=checkbox]').each(function(i) {
+ if (this.selectedIndex)
+ inputs[i].selectedIndex = this.selectedIndex;
+ if (this.checked)
+ inputs[i].checked = true;