开发者

Text box appear on radio button check

I have the following..

<table id='table_columns'>
    &l开发者_StackOverflowt;td align="center">
        <input type="radio" name="WIDTH" value="1" <?php echo ($config->get('WIDTH','COLUMNS') == "1")?'CHECKED':'';?> />
        <p>4 Columns</p>
    </td>
    <td align="center">
        <input type="radio" name="WIDTH" value="2" <?php echo ($config->get('WIDTH','COLUMNS') == "2")?'CHECKED':'';?> />
        <p>3 Columns</p>
    </td>
    <td align="center">
        <input type="radio" name="WIDTH" value="3" <?php echo ($config->get('WIDTH','COLUMNS') == "3")?'CHECKED':'';?> />
        <p>Custom</p>
    </td>
    <tr>
        <td align="right">
            <p>Column 1</p>
        </td>
        <td align="left">
            <input class="txt" size="3" maxlength="3"  name="WIDTH1" Title="Insert the desired width" value="<?php echo $config->get('WIDTH1','COLUMNS')?>" />
        </td>
    </tr>

When the Custom radio button is checked I would like the text box below to appear. If any of the other radio buttons are checked I don't want it to show. How would I do this?

Thanks


If the radio buttons map to the next rows cell you can try this:

<script type="text/javascript">
    $(function(){
        $("table input:radio").click(function(){
            var $radio = $(this);
            var index = $radio.closest("td").index();
            $radio.closest("tr").next().find("input:text").eq(index)
                .toggle($radio.is(":checked"));
        });
    });
</script>

or if there is only 1 textbox in the next row you can try:

<script type="text/javascript">
    $(function(){
        $("table input:radio").click(function(){
            var $radio = $(this);
            $radio.closest("tr").next().find("input:text")
                .toggle($radio.is(":checked"));
        });
    });
</script>

Your markup looks invalid or you just copied/pasted it wrong

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜