Javascript create_row()函数存在问题
全部, 此javascript代码根据用户选择的下拉框动态添加输入框。我几乎把它放在了需要的地方,但是现在,当我测试时,“msds_copy”和“cofa_copy”案例都显示了“html2”的相同数据。“msds_copy”选项应使第二个表单框显示“地区/语言”,而不是“批号” 你知道为什么会这样吗Javascript create_row()函数存在问题,javascript,forms,dojo,Javascript,Forms,Dojo,全部, 此javascript代码根据用户选择的下拉框动态添加输入框。我几乎把它放在了需要的地方,但是现在,当我测试时,“msds_copy”和“cofa_copy”案例都显示了“html2”的相同数据。“msds_copy”选项应使第二个表单框显示“地区/语言”,而不是“批号” 你知道为什么会这样吗 inquiry_type_onchange: function(e) { var place_order = 1, order_status = 2,
inquiry_type_onchange: function(e) {
var place_order = 1,
order_status = 2,
telalert_signup = 3,
invoice_questions = 4,
msds_copy = 5,
cofa_copy = 6,
html = null,
html2 = null,
inquiry = e.target,
id = "inquiry_type_addendum",
form_row = dojo.query("."+id);
//Clear any possible previous additions.
if (form_row != null)
form_row.forEach(dojo.destroy);
//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 msds_copy:
html = this.create_form_row(id, "Product Name:");
html2 = this.create_form_row(id + "_2", "Region / Language:");
case cofa_copy:
html = this.create_form_row(id, "Product Name:");
html2 = this.create_form_row(id + "_2", "Batch Number:");
default:
}
if (html == null) return;
//Place the new element below the inquiry_type field.
var placeat = dojo.byId('buttons');
dojo.place(html, placeat, "before");
if(html2!=null)
dojo.place(html2, placeat, "before");
},
create_form_row: function(id, label) {
//Container
var a = dojo.create("div", { id: id, className: "question inquiry_type_addendum", 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 full_number", name: label }, d);
dojo.place(d, c);
dojo.place(c, a);
return a;
}
});
您缺少了
中断
s,正在执行开关案例msds\u copy
,然后进入下一案例cofa\u copy
case msds_copy:
html = this.create_form_row(id, "Product Name:");
html2 = this.create_form_row(id + "_2", "Region / Language:");
break; // <----
case cofa_copy:
html = this.create_form_row(id, "Product Name:");
html2 = this.create_form_row(id + "_2", "Batch Number:");
break; // <----
案例msds\u副本:
html=this.create_form_行(id,“Product Name:”);
html2=this.create_form_row(id+“_2”,“Region/Language:”);
中断;// 您缺少了中断
s,正在执行开关案例msds\u copy
,然后进入下一案例cofa\u copy
case msds_copy:
html = this.create_form_row(id, "Product Name:");
html2 = this.create_form_row(id + "_2", "Region / Language:");
break; // <----
case cofa_copy:
html = this.create_form_row(id, "Product Name:");
html2 = this.create_form_row(id + "_2", "Batch Number:");
break; // <----
案例msds\u副本:
html=this.create_form_行(id,“Product Name:”);
html2=this.create_form_row(id+“_2”,“Region/Language:”);
中断;//哦,哇。在这里盯着屏幕看太久了!非常感谢!哦,哇。在这里盯着屏幕看太久了!非常感谢!