This article mainly introduces the type conversion functions of asp and js. Friends in need can refer to it.
Convert string to integer
asp:
cint()--Note that only short integer values can be converted and the range must be between -32768 and 32767. For long integers, clng() should be used
If the input is not a pure numeric string or an empty string, a 500 error will occur. So you should check whether it is a numeric type before inputting.
Copy the code as follows:Function JCID(ByVal ParaValue)
If ((Not isNumeric(ParaValue)) or (Trim(ParaValue)=)) Then
JCID=0
Else
JCID=ParaValue
End If
End function
Convert between various types to the required format:
cstr(): Convert to character
cdate(): Convert to date
cint(): Convert to integer
Clng(): Convert to long integer Long
CBool(): Convert to logical Boolean
CByte (): Convert to Byte Byte
CSng(): Convert to single-precision floating-point number Single
CDbl(): Convert to double-precision floating-point number Double
CCur(): Convert to currency format Currency
javascript:
parseInt()--Convert to integer. Note: After conversion, you should use the isNaN function to check the result. If the input is not a pure numeric string, the result will be NaN.
parseInt(abc) // Return NaN.
parseInt(12abc) // Return 12.
Note: parseInt(08) returns 0. If the string starts with 0, it is understood as octal, so 08 is an illegal string.
parseInt(08,10) returns 8 because decimal is specified.
<html xmlns=http://www.w3.org/1999/xhtml ><head><title>Title page</title><script LANGUAGE=JavaScript>var info = new Array(); //Create array object info ['name'] = 'Zhang San'; //Set an item in the array, note that the index is a string type info['age'] = '26'; //Set the second item in the array var i=0 ;for(var n in info) //Traverse each item in the array { i++; //Used to get the number of elements in the array}alert (a total of +i+ elements); //Display the total number of elements in the array</script></head>< body></body></html>