开发者

javascript/jquery/html value display while clicking

have a page that displays a list of records. The user can select the amount status using radio buttons,

If(isset($_POST['rmr'])) {

//$addtocart = $_POST['rmr'];// ?>
    input type="radio" name="rmr"  id="payment1" value="30" onclick="updatepayment(this.value)" 
    input type="radio" name="rmr"  id="payment2" value="55" onclick="updatepayment(this.value)" 
    input type="radio" name="rmr"  id="payment4" value="100" onclick="updatepayment(this.value)" 

after that i used the below query

$(document).ready(  
    function()  {
        // find the checked input and store it as "currChecked" for the record
        $("#finalpayment").data("currChecked", 
                           开发者_运维技巧  $(this).find("input:radio:checked")[0]);
        // add the click event
        $("#finalpayment").click( function(event) {
                 if ($(event.target).is("input:radio") && 
                     event.target !== $(this).data("currChecked")) 
                 {
                    $(this).data("currChecked", event.target);
                    handleChangeEvent(event);
                 }
            });

        });
    }
);

update payment(currentvalue)
{
    document.getElementById("finalamount").innerHTML=(document.getElementById("totalamount").value*currentvalue);
}

what i actually want when user clicks the button that value should display on the browser but result is null can any one tell the problem else which code i have to follow. have a nice day


what i actually want when user clicks the button that value should display on the browser but result is null can any one tell the problem else which code i have to follow. have a nice day

Could you not just use the :checked pseudo class, put a click event on the radio buttons themselves instead of inlining them in the tags?
Example:

$(document).ready(function(){

$("input[name=rmr]").click(function()
{
    if( $("input[name=rmr]:checked").length > 0 ) //make sure one is checked
    {
        $("#finalamount").html( $("#totalamount").val() * $("input[name=rmr]:checked").val() );
    }
});

});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜