Skip to content

Commit

Permalink
Some code tidying, also matching code for easier editing, and double-…
Browse files Browse the repository at this point in the history
…checking that isset statements work properly when generating javascript code.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@785 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Nov 25, 2003
1 parent 7fb4148 commit 2e52a52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
7 changes: 3 additions & 4 deletions group.php
Expand Up @@ -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 = "";
Expand All @@ -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";
Expand All @@ -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";
Expand Down
20 changes: 14 additions & 6 deletions survey.php
Expand Up @@ -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]}";
Expand All @@ -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";
Expand Down

0 comments on commit 2e52a52

Please sign in to comment.