I have a value as "SPAS1_4_2"
under which SPAS is fixed. I want to fetch the value 4
and 2
under different variable. these value can change based on a click however the _ will remain same.
How can I get 4 and 2 value in seprate variable
I have a value as "SPAS1_4_2"
under which SPAS is fixed. I want to fetch the value 4
and 2
under different variable. these value can change based on a click however the _ will remain same.
How can I get 4 and 2 value in seprate variable
You can split your string using
var str = 'SPAS1_4_2';
var pieces = str.split('_');
document.write('Pieces: ' + pieces + '</br>');
document.write('Pieces[1]: ' + pieces[1] + '</br>');
document.write('Pieces[2]: ' + pieces[2]);