I cannot disable link on non-zero date

混江龙づ霸主 提交于 2019-12-24 05:25:07

问题


    <tr bgcolor="<?php echo $rowColor ?>"  >
        <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td>
        <td><font face="Arial, Helvetica, sans-serif"><?php echo $f5; ?></font></td>
        <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td>
        <td><font face="Arial, Helvetica, sans-serif"><?php echo $deliv_date; ?></font></td>
    </tr>
    <?php
        $i++;
        }
        mysql_close();

    ?>
    <tr bgcolor="<?php echo $rowColor ?>"  >
        <td>
            <strong>Total:</strong>
        </td>
        <td colspan="1">&nbsp;</td>
        <td ><font face="Arial, Helvetica, sans-serif"><?php echo $f8; ?></font></td>
        </td>
    </tr>
</table>
</div>
<div id="footer">
    <hr/>
    <div class="buttonwrapper">
        <a  class="boldbuttons" href="invoice_conf.php" <?php if ($deliv_date !=  '0000-00-00') echo 'disabled="disabled"' ?>><span>confirm delivery</span> </a>
    </div>

I am trying to disable the link in the last div when there is a non-zero delivery date. As you can see in the attached screen shot, I have a non-zero delivery date. When I try the link it is not disabled. Does anyone know why this could be,

Thanks


回答1:


Adding disabled attribute won't disable the link, if you want, just echo an # instead of the real source, or with Javascript, adding javascript: void(0)

Demo

<a class="boldbuttons" href="<?php echo ($deliv_date != '0000-00-00') ? 'invoice_conf.php' : 'javascript: void(0)'; ?>">
    <span>confirm delivery</span>
</a>

Or you can also use a class say disabled_link and if you want to prevent with pure CSS than use pointer-events: none;

Demo

Demo (Can also use lighter shades to indicate that the link is disabled)

.disabled_link {
    pointer-events: none;
    cursor: default;
}

Support for pointer-events is not impressive when it comes to Internet Explorer, I would suggest you to use span instead, like if the date is not 0000-00-00, then echo the text in span tags, else echo <a>




回答2:


add this after href.

onclick="return false;"

disabled is attribute for input tag.



来源:https://stackoverflow.com/questions/22039837/i-cannot-disable-link-on-non-zero-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!