如何在下面的代码中将字符串转换为整数 [英] how to convert string to integer in below code

查看:59
本文介绍了如何在下面的代码中将字符串转换为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

 qcAllocationDetails.BatchId = $( #batchIDSelect选项:选中)。map(function(){
return $( this )。val();
})。 get ()。 join ' ,');
console.log(qcAllocationDetails.BatchId);





我的控件如下:

< select id =   batchIDSelect name =   batchIDSelect class =   combo100 multiple =   multiple> 
< / select>





我可以从BatchId中选择多少个值。我的BatchId是Integer.Values是1, 2,3 ...依此类推

它给我的错误无法将字符串转换为整数。无论如何都要排序这个问题。

在我上面的代码中,我应该做哪些更改。请指导我。我想传递一个字符串而不是整数。怎么可能。



谢谢

Harshal。

解决方案

#batchIDSelect选项:已选中)。map(function(){
return


this )。val();
})。 get ()。 join ' ,');
console.log(qcAllocationDetails.BatchId);





我的控件如下:

< select id =   batchIDSelect name =   batchIDSelect class =   combo100 multiple =   multiple> 
< / select>





我可以从BatchId中选择多少个值。我的BatchId是Integer.Values是1, 2,3 ...依此类推

它给我的错误无法将字符串转换为整数。无论如何都要排序这个问题。

在我上面的代码中,我应该做哪些更改。请指导我。我想传递一个字符串而不是整数。怎么可能。



谢谢

Harshal。


什么转换?这意味着解析字符串以将其解释为整数。请参阅:

http://www.iidproductions.com/JStutorials/Basics/parseInt .asp [ ^ ],

http://jsfiddle.net/ERpqM/2 [ ^ ]。



-SA

I have the Code As follows :

qcAllocationDetails.BatchId = $("#batchIDSelect option:selected").map(function () {
       return $(this).val();
}).get().join(',');
   console.log(qcAllocationDetails.BatchId);



Ihave the controls as follows:

<select id="batchIDSelect" name="batchIDSelect" class="combo100" multiple="multiple">
                        </select>



I can select number of values from BatchId .My BatchId is Integer.Values are 1,2,3...and so on
its gives me error could not convert string to integer.Is there anyway to sort this problem.
In my above code ,where should i make the changes.Please guide me.I want to pass a string instead of integer .How is it possible.

Thanks
Harshal.

解决方案

("#batchIDSelect option:selected").map(function () { return


(this).val(); }).get().join(','); console.log(qcAllocationDetails.BatchId);



Ihave the controls as follows:

<select id="batchIDSelect" name="batchIDSelect" class="combo100" multiple="multiple">
                        </select>



I can select number of values from BatchId .My BatchId is Integer.Values are 1,2,3...and so on
its gives me error could not convert string to integer.Is there anyway to sort this problem.
In my above code ,where should i make the changes.Please guide me.I want to pass a string instead of integer .How is it possible.

Thanks
Harshal.


What "convert"? It means parsing string to interpret it as integer. Please see:
http://www.iidproductions.com/JStutorials/Basics/parseInt.asp[^],
http://jsfiddle.net/ERpqM/2[^].

—SA


这篇关于如何在下面的代码中将字符串转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆