简体   繁体   English

动态添加输入框有问题吗?

[英]Dynamically added input box problem?

I have dynamically added div.In which i have text box.While adding dynamic div i can put a value to the current div but not the previously open divs. 我已经动态添加了div。在其中有文本框。在添加动态div的同时,我可以为当前div设置一个值,但不能为之前打开的div设置值。 I want to ask how to add Value to the previously open text boxes of Div. 我想问一下如何在Div的先前打开的文本框中添加Value。

Thank You 谢谢

here is a solution that refresh ALL . 这是刷新ALL的解决方案。 (I don't understand the "previously open text box" part of your question. Well I understand it, but it doesn't show in your code. I assume the "rhythm" column of your table is an input/textarea html element (since you use it's value). (我不理解您问题的“先前打开的文本框”部分。嗯,我理解了,但是它没有显示在您的代码中。我假设表的“节奏”列是input / textarea html元素(因为您使用它的价值)。

Please note I'm not sure what the vitalset function is supposed to accomplish, or what "vitals_form_readings_1_rhythm" is. 请注意,我不确定vitalset函数应该完成什么,或者“ vitals_form_readings_1_rhythm”是什么。

function queryDb(statement)
{
    dbQuery = new air.SQLStatement();
    dbQuery.sqlConnection = db;
    dbQuery.text = statement //"SELECT * FROM rhythm";
    //alert(dbQuery.text);
    try {
        dbQuery.execute();
        } catch (error) {
        air.trace("Error retrieving notes from DB:", error);
        air.trace(error.message);
    return;
    }
    return (dbQuery.getResult());
}

function crhythm()
{
    var statement = "SELECT * FROM rhythm";
    return queryDb(statement)
}

function reading_speedcode()
{
    if (!cvitals) {
        var crhythms = crhythm();
        var i=0;
        $(crhythms).each( function () {
            crhythm = this.crhythm;
            var pr = 'card_' + i;
            $('#rhythm1').append('<br/><td class="content_big" id="'+pr+'" name="'+pr+'">' + crhythm + ' </td>');
            i++
        });
    }
});

$(document).ready( function () {
    reading_speedcode();

    $('#rhythm1 .content_big').live('click', function(event) {
        $('#rhythm1').empty()
        reading_speedcode();
    });
});

now, there are several things about your code. 现在,关于您的代码有几件事。

  1. variable naming. 变量命名。 (for god sake use meaningful names!) (为了上帝,使用有意义的名称!)
  2. reading full table when you need one row 需要一排时阅读全表
  3. where is cvitals declared or assigned? 活体在哪里申报或分配?
  4. string parsing. 字符串解析。 Jquery is good at working with set of elements, there should be no need to parse "pr" to recover the row number. jQuery擅长使用元素集,因此无需解析“ pr”即可恢复行号。
  5. if a value is inserted in rhythm table (or deleted) before your click, the vitalset logic fails. 如果在您单击之前在节奏表中插入(或删除)一个值,那么vitalset逻辑将失败。 you might want to use the table id instead. 您可能要改用表格ID。
  6. make sure "#vitals_form_readings_1_rhythm" is unique, not retrieved from the table. 确保“#vitals_form_readings_1_rhythm”是唯一的,而不是从表中检索到的。

if you can answer my question from the top of this post(vitalset function, vitals_form_readings_1_rhythm, cvitals) I will try improve the code. 如果您可以从这篇文章的顶部回答我的问题(vitalset函数,vitals_form_readings_1_rhythm,cvitals),我将尝试改进代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM