Havoux Havoux - 1 year ago 66
Javascript Question

PHP+HTML - If Else, Hide Button

This is my php code:

if ($value = $rec['ip'] <= $cphigh_ip && $cplow_ip <= $value = $rec['ip'])
{
$cpyes="on ";
$realString = $value = $rec['ip'];
$whmLink=$realString[strlen($realString)-1];
}
else
{
$cpno="not on cPanel";
}


And the HTML table I have is pretty simple:

<tr>
<td>Domain IP:</td>
<td><?=$ipyes.$ipno.$cpyes.$cpno;?><input type="submit" name="cPanelButton" onClick="window.location.href='https://cp<?=$whmLink; ?>.skycomp.ca:2087'" value="cPanel"></td>
</tr>


Is there a way to hide the button in the else clause? or even create the button in that specific in the if statement?

Answer Source

You can put button in to php code

if ($value = $rec['ip'] <= $cphigh_ip && $cplow_ip <= $value = $rec['ip'])
    {
        $cpyes="on ";
        $realString = $value = $rec['ip'];
        $whmLink=$realString[strlen($realString)-1];
        $ifwhmlink = '<input type="submit" name="cPanelButton"   onClick="window.location.href=\'https://cp'.$whmLink.'.skycomp.ca:2087\'" value="cPanel">';
    }
    else
    {
        $cpno="not on cPanel";
        $ifwhmlink = "";
    }

<tr>
    <td>Domain IP:</td>
    <td><?=$ipyes.$ipno.$cpyes.$cpno.$ifwhmlink;?></td>
</tr>