From 7487cf7b678a8dfa2464e367e0b5d52f409c9830 Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Thu, 29 Nov 2012 11:16:02 +0100 Subject: [PATCH] Fixed issue #6960: Unchecking of "other" option in multiple choice questions impossible if text box empty Dev: return false on click, but put error on text input and focus in Dev: Add inline visibility:hidden style for user without javascript, remove it in javascript Dev: can be put in external js file, but use .live or .delegate to have it before document.loading --- application/helpers/qanda_helper.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php index f7b832a433a..fd5869acb47 100644 --- a/application/helpers/qanda_helper.php +++ b/application/helpers/qanda_helper.php @@ -2387,16 +2387,14 @@ function do_multiplechoice($ia) } $answer .= $startitem; $answer .= $hiddenfield.' - getConfig('surveyID')][$myfname]) && trim($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname])!='') { $answer .= CHECKED; } - $answer .= " onclick='cancelBubbleThis(event);if(this.checked===false){ document.getElementById(\"answer$myfname\").value=\"\"; document.getElementById(\"java$myfname\").value=\"\"; $checkconditionFunction(\"\", \"$myfname\", \"text\"); }"; - $answer .= " if(this.checked===true) { document.getElementById(\"answer$myfname\").focus(); }; LEMflagMandOther(\"$myfname\",this.checked);"; - $answer .= "' /> + $answer .= " /> getConfig('surveyID')][$myfname])) @@ -2408,11 +2406,15 @@ function do_multiplechoice($ia) } $answer .= htmlspecialchars($dispVal,ENT_QUOTES); } -# $answer .= "\" onkeyup='if ($.trim(this.value)!=\"\") { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"checked\"); } else { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"\"); }; $(\"#java{$myfname}\").val(this.value);$oth_checkconditionFunction(this.value, this.name, this.type); LEMflagMandOther(\"$myfname\",\$(\"#answer{$myfname}cbox\").attr(\"checked\"));'/>"; $answer .="\" />"; $answer .="\n"; $answer .= '