如何在具有多个值的jQuery选项中添加破折号
我有一个POS系统,我从三个字段获取客户数据<代码>姓名,如何在具有多个值的jQuery选项中添加破折号,jquery,Jquery,我有一个POS系统,我从三个字段获取客户数据姓名,电子邮件和手机 假设值为: Name = Owais Email = owais@gmail.com Mobile = 03214834289 我正在用这个代码加载这个 for (var i = 0; i < jsonData.categories.length; i++) { var counter = jsonData.categories[i]; var cust_id = counter.cu
电子邮件
和手机
假设值为:
Name = Owais
Email = owais@gmail.com
Mobile = 03214834289
我正在用这个代码加载这个
for (var i = 0; i < jsonData.categories.length; i++) {
var counter = jsonData.categories[i];
var cust_id = counter.cust_id;
var cust_name = counter.cust_name;
var cust_emai = counter.cust_email;
var cust_mobile = counter.cust_mobile;
option = document.createElement( 'option' );
option.value = cust_id;
option.text = cust_name + cust_email + cust_mobile;
select.add( option );
}
如何在输出中添加破折号?最简单的方法是将option.text设置为
cust_name + " - " + cust_email + " - " + cust_mobile;
这样说:
option = document.createElement( 'option' );
option.value = cust_id;
option.text = cust_name + " - " + cust_email + " - " + cust_mobile;
select.add( option );
将它们连接到您正在构建的字符串:
cust_name+'-'+cust_email+'-'+cust_mobile
只需更换instroption.text=cust_name+“-”+cust_email+“-”+cust_mobile代码>谢谢:)它正在工作。Stackoverflow是最好的
option = document.createElement( 'option' );
option.value = cust_id;
option.text = cust_name + " - " + cust_email + " - " + cust_mobile;
select.add( option );