duanbo1659 2016-06-05 11:32
浏览 45

如何基于PHP布尔值启用HTML按钮?

I'm trying to have a button enabled\disabled based on the value of a Boolean the button disabling works however when I try enabling when I require the button to be enabled(after being disabled) it does not work

<?php
if($init==0){
    echo "init";
    $booleanSubmitDataButtonDisabled= 1;
    $booleanGetDataButtonDisabled =0;
}
?>
<?php
if (isset($_POST['getData'])&&!($booleanOwnerId)) {
    $actionIsdone =1;
    if($actionIsdone){
        disableGetDataEnableSubmit();
    }
}
function disableGetDataEnableSubmit(){
    $init++;
    $booleanGetDataButtonDisabled = 1;
    $booleanSubmitDataButtonDisabled = 0;
    $booleanSelectorDisabled =1;
}
?>

and in my form:

<td><input type="submit" name="getData" value="Get Data For Selected Action"/></td>
<?php if($booleanSubmitDataButtonDisabled){
                echo "<td><input type='submit'  name='submit' value='Submit' disabled /></td>";
                }else{echo "<td><input type='submit'  name='submit' value='Submit'  /></td>";}  ?>
            <td><input type="reset" name="reset" value="Clear" <?php if($booleanGetDataButtonDisabled) echo 'disabled="disabled"' ?> /></td>

Am I required to somehow make the html in the page refresh? I cannot use JavaScript unless this problem absolutely cannot be overcome by using PHP.
Please help with this as I am at my wits end with this problem.
Thanks in advance
Edit: It seems that what I'm trying to achieve cannot be accomplished with PHP, I'll welcome any answer that shows me how to do this simply Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 potsgresql15备份问题
    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错
    • ¥15 单片机学习顺序问题!!
    • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上