开发者

Create Form Row with Dojo

I am new to Dojo and working with someone else's code. Currently, this function looks to see the value of a dropdown box. Based on that value, it adds another form box, on the fly, for a user to fill out. In all the examples I have, I've only seen the function create one added form box. In a particular case, though, I'd like to add a second row with another form box. I thought maybe repeating the line twice would do the trick, but it doesn't. Any thoughts how to do this? Thanks in advance...

Switch Statement:

if (form_row != null)
    dojo.destroy(form_row);
//Add the correct new field to the form.
switch (inquiry.selectedIndex) {
    case place_order:
        html = this.create_form_row(id, "Account Number");
        break;
    case order_status:
        html = this.create_form_row(id, "Order Number");
        break;
    case telalert_signup:
        html = this.create_form_row(id, "Account Number");
        break;
    case invoice_questions:
        html = this.create_form_row(id, "Invoice Number");
        break;
    case new_option:
        html = this.create_form_row(id, "Invoice Number");
        (WANT TO CREATE A SECOND ROW HERE!)
        break;
    default:
}

Function being called:

create_form_row: function(id, label) {
    //Container
    var a = dojo.create("div", { id: id, className: "question", style: "padding-top:4px;" });
    //Label
    var b = dojo.create("div", { className: "label", innerHTML: label, style: "margin-top:8px;" }, a);
    //Field
    var c = dojo.create("div", { className: "field" });
    var d = dojo.create("span", { className: "full_number_span span" })开发者_开发知识库;
    var e = dojo.create("input", { type: "text", className: "textbox acct_num", name: label }, d);
    dojo.place(d, c);
    dojo.place(c, a);
    return a;
}


If you tried

case new_option:
    html = this.create_form_row(id, "Invoice Number");
    html = this.create_form_row(id, "SOMETHING ELSE");
    break;

it wouldn't work because you would just overwrite the html variable and throw away the first one.

You can either change stuff so that html is supposed to be a list of nodes or you can try wrapping your two form nodes inside a single one

var html = dojo.create('div');
dojo.place(this.create_form_row(...), html);
dojo.place(this.create_form_row(...), html);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜