irishwill200 irishwill200 - 2 months ago 7
HTML Question

If statement causes page not to load

I have a switch (checkboxes) and when

$checkedans = true
then flip the switch to checked else leave default (unchecked).

The error is when I try load the page it just goes white screen.

The switch and all works perfectly without the php inside but I need the if statement. Anyone know why this is happening / know a fix?

My code:

echo"
<td class=\"alarmvalue\" style=\"padding:2px 15px;\">
<label class=\"switch-lightp2 well_\" onchange=\"checkSelectedScheduleType()\">";
if ($checkedans == true) {
echo "<input id=\"radioSelected\" name=\"radioSelected\" type=\"checkbox\" value=\"\" checked>\n"
}else{
echo "<input id=\"radioSelected\" name=\"radioSelected\" type=\"checkbox\" value=\"\">\n";
}
echo" <span><span>keep</span><span>remove</span></span><a class=\"btn btn-primary\"></a>
</label>
</td> "

Answer

Issue was due to a missing semicolon.

On line:

echo "<input id=\"radioSelected\" name=\"radioSelected\" type=\"checkbox\" value=\"\" checked>\n"

Should be:

echo "<input id=\"radioSelected\" name=\"radioSelected\" type=\"checkbox\" value=\"\" checked>\n";
Comments