0

我无法调用该函数,credit_edit()尤其是在 chrome 中,但它在 firefox 中有效。

我不知道问题出在哪里

我从

onkeyup (onkeyup = 'credit_edit(this.value)')

请有人为此提供解决方案。

credit_apply() 是主要功能。只有我从这个函数调用。

credit_edit(this.value)在 credit_apply() 函数中使用了这段代码

function credit_apply(change){
        $.ajax({
            url: 'ajax/order_details.php?order_id=<?php echo $_GET['id']; ?>',
            dataTypes: 'json',
            type: 'GET',
            success: function(json){
                if(change=='apply'){
                    $('#credit_apply').html('<button type="button" name="apply" onClick="credit_apply(\'undo\');" id="apply" style="margin-left:52px; margin-top:10px;" class="new-row float_left button orange-gradient glossy">Undo Changes</button>');


                    if_total = $('#title_value'+json).val();
                    if_return = $('#return_credit').val();
                    if(parseFloat(if_total) <= parseFloat(if_return)){
                        get_value = parseFloat(if_return) - parseFloat(if_total);
                        credit_value = $('#credit_value').val();
                        $('#title_value'+json).val(0);
                        $('#numner_text'+json).html('$0');
                        $("#credit"+json).html('<td align="right" colspan="4"><span id="credit_title_text">Credit Amount( - )</span><input id="credit_value" type="hidden" value="' + if_total + '" name="credit_value"><input id="credit_original" type="hidden" name="credit_original" value="' + if_total + '"></td><td align="right" onclick="credit_id();"><span id="credit_title_value">$' + if_total + '</span><input class="input" size="5" id="credit_edit" onkeyup="credit_edit(this.value);" type="text" style="display:none" value="' + if_total + '" name="credit_edit"></td>');
                    }else{
                        get_value = (parseFloat(if_total) - parseFloat(if_return)).toFixed(2);
                        credit_value = $('#credit_value').val();
                        $('#title_value'+json).val(get_value);
                        $('#numner_text'+json).html('$'+get_value);
                        $("#credit"+json).html('<td align="right" colspan="4"><span id="credit_title_text">Credit Amount( - )</span><input id="credit_value" type="hidden" value="' + if_return + '" name="credit_value"><input id="credit_original" type="hidden" name="credit_original" value="' + if_return + '"></td><td align="right" onclick="credit_id();"><span id="credit_title_value">$' + if_return + '</span><input class="input" size="5" id="credit_edit" onkeyup="credit_edit(this.value);" type="text" style="display:none" value="' + if_return + '" name="credit_edit"></td>');
                    }

                }else{
                    $('#credit_apply').html('<button type="button" name="apply" onClick="credit_apply(\'apply\');" id="apply" style="margin-left:80px; margin-top:10px;" class="new-row float_left button green-gradient glossy">Apply</button>');
                    original = $('#original_total').val();
                    $('#credit'+json).html('<input id="credit_value" type="hidden" value="0" name="credit_value">');
                    $('#title_value'+json).val(original);
                    $('#numner_text'+json).html('$'+original);
                }
            }
        });
    }












function credit_edit(value){
        original_c = document.getElementById("credit_original").value;
        searc = value.search(" ");
        if(value==''||value=='null'){
            $('#credit_edit').val(0);
            $('#credit_value').val(0);
            apply_change(0);
        }else if(isNaN(value)){
            $('#credit_edit').val(original_c);
            $('#credit_value').val(original_c);
            apply_change(original_c);
        }else if(searc!=-1){
            $('#credit_edit').val(original_c);
            $('#credit_value').val(original_c);
            apply_change(original_c);
        }else if(parseFloat(original_c) >= parseFloat(value)){
            $('#credit_value').val(value);
            apply_change(value);
        }else{
            $('#credit_edit').val(original_c);
            $('#credit_value').val(original_c);
            apply_change(original_c);
        }
    }
4

1 回答 1

0

尝试取出 html 中的所有“onkeyup”事件,然后在“if change=..”语句的末尾执行以下操作:

if(change=='apply'){
                $('#credit_apply').html('<button type="button" name="apply" onClick="credit_apply(\'undo\');" id="apply" style="margin-left:52px; margin-top:10px;" class="new-row float_left button orange-gradient glossy">Undo Changes</button>');


                if_total = $('#title_value'+json).val();
                if_return = $('#return_credit').val();
                if(parseFloat(if_total) <= parseFloat(if_return)){
                    get_value = parseFloat(if_return) - parseFloat(if_total);
                    credit_value = $('#credit_value').val();
                    $('#title_value'+json).val(0);
                    $('#numner_text'+json).html('$0');
                    $("#credit"+json).html('<td align="right" colspan="4"><span id="credit_title_text">Credit Amount( - )</span><input id="credit_value" type="hidden" value="' + if_total + '" name="credit_value"><input id="credit_original" type="hidden" name="credit_original" value="' + if_total + '"></td><td align="right" onclick="credit_id();"><span id="credit_title_value">$' + if_total + '</span><input class="input" size="5" id="credit_edit" onkeyup="credit_edit(this.value);" type="text" style="display:none" value="' + if_total + '" name="credit_edit"></td>');
                }else{
                    get_value = (parseFloat(if_total) - parseFloat(if_return)).toFixed(2);
                    credit_value = $('#credit_value').val();
                    $('#title_value'+json).val(get_value);
                    $('#numner_text'+json).html('$'+get_value);
                    $("#credit"+json).html('<td align="right" colspan="4"><span id="credit_title_text">Credit Amount( - )</span><input id="credit_value" type="hidden" value="' + if_return + '" name="credit_value"><input id="credit_original" type="hidden" name="credit_original" value="' + if_return + '"></td><td align="right" onclick="credit_id();"><span id="credit_title_value">$' + if_return + '</span><input class="input" size="5" id="credit_edit" onkeyup="credit_edit(this.value);" type="text" style="display:none" value="' + if_return + '" name="credit_edit"></td>');
                }
             //HERE
              $("#credit_edit").keyup(function(event)
              {
                 credit_edit($(this).val());
              });
            }else{
                $('#credit_apply').html('<button type="button" name="apply" onClick="credit_apply(\'apply\');" id="apply" style="margin-left:80px; margin-top:10px;" class="new-row float_left button green-gradient glossy">Apply</button>');
                original = $('#original_total').val();
                $('#credit'+json).html('<input id="credit_value" type="hidden" value="0" name="credit_value">');
                $('#title_value'+json).val(original);
                $('#numner_text'+json).html('$'+original);
            }
于 2013-02-26T14:45:13.177 回答