diff --git a/group.php b/group.php index 1274bd40a97..4144f2c5104 100644 --- a/group.php +++ b/group.php @@ -696,17 +696,17 @@ echo "\t\t\t{\n"; if (is_array($conditions)) { + if (!isset($endzone)) {$endzone="";} echo "\t\t\tif (type == 'radio')\n"; echo "\t\t\t\t{\n"; echo "\t\t\t\tvar hiddenformname='java'+name;\n"; echo "\t\t\t\tdocument.getElementById(hiddenformname).value=value;\n"; echo "\t\t\t\t}\n"; $java=""; - $endzone=""; $cqcount=1; foreach ($conditions as $cd) { - if (isset($oldq) && $oldq != $cd[0]) //New if statement + if ((isset($oldq) && $oldq != $cd[0]) || !isset($oldq)) //New if statement { $java .= $endzone; $endzone = ""; @@ -728,7 +728,6 @@ else {$idname=$cd[2];} if ($cqcount > 1 && $oldcq ==$cd[2]) {$java .= " || ";} elseif ($cqcount >1 && $oldcq != $cd[2]) {$java .= ") && (";} - if ($cd[3] == '') { $java .= "document.getElementById('$idname').value == ' ' || !document.getElementById('$idname').value"; @@ -741,7 +740,7 @@ { $java .= "document.getElementById('$idname').value == '$cd[3]'"; } - if (isset($oldq) && $oldq != $cd[0])//Close if statement + if ((isset($oldq) && $oldq != $cd[0]) || !isset($oldq))//Close if statement { $endzone = "))\n"; $endzone .= "\t\t\t\t{\n"; diff --git a/survey.php b/survey.php index c74ad28cd8c..f16389f5a5c 100644 --- a/survey.php +++ b/survey.php @@ -672,14 +672,14 @@ $cqcount=1; foreach ($conditions as $cd) { - if ($oldq != $cd[0]) //New if statement + if ((isset($oldq) && $oldq != $cd[0]) || !isset($oldq)) //New if statement { $java .= $endzone; $endzone = ""; $cqcount=1; $java .= "\n\t\t\tif (("; } - if (!$oldcq) {$oldcq = $cd[2];} + if (!isset($oldcq) || !$oldcq) {$oldcq = $cd[2];} if ($cd[4] == "L" && $dropdowns == "R") //Just in case the dropdown threshold is being applied, check number of answers here { $cccquery="SELECT code FROM {$dbprefix}answers WHERE qid={$cd[1]}"; @@ -694,11 +694,19 @@ else {$idname=$cd[2];} if ($cqcount > 1 && $oldcq ==$cd[2]) {$java .= " || ";} elseif ($cqcount >1 && $oldcq != $cd[2]) {$java .= ") && (";} - if ($cd[3] == '') {$java .= "document.getElementById('$idname').value == ' ' || !document.getElementById('$idname').value";} + if ($cd[3] == '') + { + $java .= "document.getElementById('$idname').value == ' ' || !document.getElementById('$idname').value"; + } elseif($cd[4] == "M" || $cd[4] == "O" || $cd[4] == "P") - {$java .= "document.getElementById('$idname').checked";} - else {$java .= "document.getElementById('$idname').value == '$cd[3]'";} - if ($oldq != $cd[0])//Close if statement + { + $java .= "document.getElementById('$idname').checked"; + } + else + { + $java .= "document.getElementById('$idname').value == '$cd[3]'"; + } + if ((isset($oldq) && $oldq != $cd[0]) || !isset($oldq))//Close if statement { $endzone = "))\n"; $endzone .= "\t\t\t\t{\n";