refs #259 - refactored 7c2137eb
Showing
1 changed file
with
9 additions
and
11 deletions
... | @@ -415,13 +415,7 @@ | ... | @@ -415,13 +415,7 @@ |
415 | * @return Mixed | 415 | * @return Mixed |
416 | */ | 416 | */ |
417 | this.getFieldValue = function getFieldValue(inputName) { | 417 | this.getFieldValue = function getFieldValue(inputName) { |
418 | var inputs = this.findAll('[name="' + inputName + '"]'), type; | 418 | function getSingleValue(input) { |
419 | switch (inputs.length) { | ||
420 | case 0: | ||
421 | return null; | ||
422 | case 1: | ||
423 | //this.log(inputs[0].nodeName.toLowerCase(), "error"); | ||
424 | var input = inputs[0]; | ||
425 | try { | 419 | try { |
426 | type = input.getAttribute('type').toLowerCase(); | 420 | type = input.getAttribute('type').toLowerCase(); |
427 | } catch (e) { | 421 | } catch (e) { |
... | @@ -433,11 +427,10 @@ | ... | @@ -433,11 +427,10 @@ |
433 | // single checkbox or… radio button (weird, I know) | 427 | // single checkbox or… radio button (weird, I know) |
434 | if (input.hasAttribute('value')) { | 428 | if (input.hasAttribute('value')) { |
435 | return input.checked ? input.getAttribute('value') : undefined; | 429 | return input.checked ? input.getAttribute('value') : undefined; |
436 | } else { | 430 | } |
437 | return input.checked; | 431 | return input.checked; |
438 | } | 432 | } |
439 | break; | 433 | function getMultipleValues(inputs) { |
440 | default: | ||
441 | type = inputs[0].getAttribute('type').toLowerCase(); | 434 | type = inputs[0].getAttribute('type').toLowerCase(); |
442 | if (type === 'radio') { | 435 | if (type === 'radio') { |
443 | var value; | 436 | var value; |
... | @@ -454,7 +447,12 @@ | ... | @@ -454,7 +447,12 @@ |
454 | }); | 447 | }); |
455 | return values; | 448 | return values; |
456 | } | 449 | } |
457 | break; | 450 | } |
451 | var inputs = this.findAll('[name="' + inputName + '"]'), type; | ||
452 | switch (inputs.length) { | ||
453 | case 0: return null; | ||
454 | case 1: return getSingleValue(inputs[0]); | ||
455 | default: return getMultipleValues(inputs); | ||
458 | } | 456 | } |
459 | }; | 457 | }; |
460 | 458 | ... | ... |
-
Please register or sign in to post a comment