English 中文(简体)
• 如何选择使用“ j”在文字箱被点击时的收音机?
原标题:How to select radio button when text box is clicked with PHP using jQuery?

I have a PHP form that presents the user with two radio button options ("All Dates" vs "Date Range").

如果用户开始在“标准日期”或“到期日”中打字,我就象“Date range”无线电台。

同样,我也像“标准日期”和“到期日”文本领域一样,明确选择“所有日期”无线电台。

注:以下四部分是可加以限定的形式的一部分,因此,对贴现/姓名要素的“#index#”变量(无法确保可使用贴现/名称参考)。

<div>
    <label>Dates to Give:</label>
    <div>
        <input type="radio" name="dates_#index#" id="dates_all_#index#" class="required" value="1" />
        All dates<br />
        <input type="radio" name="dates_#index#" id="dates_range_#index#" class="required" value="0" />
        Date Range:
        <div id="give_from">
            <div>
                <label> Start Date:</label>
                <input type="text" name="start_date_#index#" id="start_date_#index#" class="date start_date" />
            </div>
            <div>
                <label> End Date:</label>
                <input type="text" name="end_date_#index#" id="end_date_#index#" class="date end_date" />
            </div>
        </div>
    </div>
</div>
最佳回答

将你的超文本(CFML)改为此(注:增加了指数=“#index#”):

<div>
    <label>Dates to Give:</label>
    <div>
        <input type="radio" name="dates_#index#" index="#index#" id="dates_all_#index#" class="required" value="1" />
        All dates<br />
        <input type="radio" name="dates_#index#" id="dates_range_#index#" class="required" value="0" />
        Date Range:
        <div id="give_from">
            <div>
                <label> Start Date:</label>
                <input type="text" name="start_date_#index#" index="#index#" id="start_date_#index#" class="date start_date" />
            </div>
            <div>
                <label> End Date:</label>
                <input type="text" name="end_date_#index#" index="#index#" id="end_date_#index#" class="date end_date" />
            </div>
        </div>
    </div>
</div>

加上本联合材料:

$(function () {


    $(".end_date, .start_date").keypress(function () {
        $("#dates_range_" + $(this).attr( index )).attr("checked", true);
    });

    $("##dates_all_#index#").click(function () {
        $("##end_date_" + $(this).attr( index ) + ", ##end_date_" + $(this).attr( index )).val("");

    });
});
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签