0

我希望将程序的输出发送到 MEdit 框,但是无论出于何种原因,html 方法都没有设置框的值,我应该改用 MLabel 吗?

这是我的代码:

函数 MButton1Click(事件) {

var temp = $("#MEdit1").val();
temp = parseInt(temp);
var selectedItem = $("input[name='MRadioGroup1']:checked").val();

if(selectedItem == 0)
{
    var five9ths = 5/9;
    temp = temp - five9ths;
    temp = temp + 32;       
    $('#MEdit3').html("C");
}
else
{
    var nine5ths = 9/5;
    temp = temp * nine5ths;
    temp = temp + 32;
    $('#MEdit3').html("F");
}
    var temperature = temp.toString();
    $('#MEdit2').html(temperature);

}

4

1 回答 1

0

您需要使用.val()而不是.html()

$('#MEdit3').val("C"); 

这是您的代码应如下所示:

function MButton1Click(event) {
    var temp = $("#MEdit1").val();
    temp = parseInt(temp);
    var selectedItem = $("input[name='MRadioGroup1']:checked").val();

    if (selectedItem == 0) {
        var five9ths = 5 / 9;
        temp = temp - five9ths;
        temp = temp + 32;
        $('#MEdit3').val("C");
    } else {
        var nine5ths = 9 / 5;
        temp = temp * nine5ths;
        temp = temp + 32;
        $('#MEdit3').val("F");
    }
    var temperature = temp.toString();
    $('#MEdit2').val(temperature);
}
于 2013-06-10T19:55:51.367 回答