I have a text input field like this:
someone types = 22x32x5
Is it possible to extract this value into 3 different text input fields without the x in jQuery? And how?
FieldB=22
FieldC=32
FieldD=5
Thanks in advance!
I have a text input field like this:
someone types = 22x32x5
Is it possible to extract this value into 3 different text input fields without the x in jQuery? And how?
FieldB=22
FieldC=32
FieldD=5
Thanks in advance!
Yes it is possible with the function split()
it splits a string into an array, use this code:
var types = "22x32x5";
var temp = new Array();
// this will return an array with strings "22", "32", "5", etc.
temp = types .split("x");
for (a in temp ) {
// Your Code here to populate to input field. You will get the value from temp[a].
}
You could use:
var string = '22x32x5';
var newstring = string.split('x');
$('#FieldB').val(newstring[0]);
$('#FieldC').val(newstring[1]);
$('#FieldD').val(newstring[2]);