How to move arrays from textarea to a table using Javascript
I'm trying to move the input result from textarea into a table. I'm using javascript to get the array value.
But what I can do now is only display it in one textarea. I'm confused how to seperate the array value into table.
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<script>
function next3(){
var vx = String($("input[name='px']").map(function(){return $(this).val();}).get());
var vy = String($("input[name='py']").map(function(){return $(this).val();}).get());
var vxArr = vx.split(",");
var vyArr = vy.split(",");
var lenArr = vxArr.length;
var isi = "";
for (i = 0; i < lenArr; i++) {
var koord = "X" + vxArr[i] + " " + "Y" + vyArr[i];
//alert (koord);
var isi = isi + ', ' + koord;
}
//alert (isi);
var lastChar = isi.substr(2); // => "1"
$("#koord").val(lastChar);
}
</script>
The result in textarea is
Image link https://postimg.cc/fJWHhxp9
What i'm expected is
+---------+---------+
| X Point | Y Point |
+---------+---------+
| 123 | 456 |
| 123 | 456 |
| 123 | 456 |
| 123 | 456 |
+---------+---------+
javascript jquery html
add a comment |
I'm trying to move the input result from textarea into a table. I'm using javascript to get the array value.
But what I can do now is only display it in one textarea. I'm confused how to seperate the array value into table.
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<script>
function next3(){
var vx = String($("input[name='px']").map(function(){return $(this).val();}).get());
var vy = String($("input[name='py']").map(function(){return $(this).val();}).get());
var vxArr = vx.split(",");
var vyArr = vy.split(",");
var lenArr = vxArr.length;
var isi = "";
for (i = 0; i < lenArr; i++) {
var koord = "X" + vxArr[i] + " " + "Y" + vyArr[i];
//alert (koord);
var isi = isi + ', ' + koord;
}
//alert (isi);
var lastChar = isi.substr(2); // => "1"
$("#koord").val(lastChar);
}
</script>
The result in textarea is
Image link https://postimg.cc/fJWHhxp9
What i'm expected is
+---------+---------+
| X Point | Y Point |
+---------+---------+
| 123 | 456 |
| 123 | 456 |
| 123 | 456 |
| 123 | 456 |
+---------+---------+
javascript jquery html
add a comment |
I'm trying to move the input result from textarea into a table. I'm using javascript to get the array value.
But what I can do now is only display it in one textarea. I'm confused how to seperate the array value into table.
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<script>
function next3(){
var vx = String($("input[name='px']").map(function(){return $(this).val();}).get());
var vy = String($("input[name='py']").map(function(){return $(this).val();}).get());
var vxArr = vx.split(",");
var vyArr = vy.split(",");
var lenArr = vxArr.length;
var isi = "";
for (i = 0; i < lenArr; i++) {
var koord = "X" + vxArr[i] + " " + "Y" + vyArr[i];
//alert (koord);
var isi = isi + ', ' + koord;
}
//alert (isi);
var lastChar = isi.substr(2); // => "1"
$("#koord").val(lastChar);
}
</script>
The result in textarea is
Image link https://postimg.cc/fJWHhxp9
What i'm expected is
+---------+---------+
| X Point | Y Point |
+---------+---------+
| 123 | 456 |
| 123 | 456 |
| 123 | 456 |
| 123 | 456 |
+---------+---------+
javascript jquery html
I'm trying to move the input result from textarea into a table. I'm using javascript to get the array value.
But what I can do now is only display it in one textarea. I'm confused how to seperate the array value into table.
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<script>
function next3(){
var vx = String($("input[name='px']").map(function(){return $(this).val();}).get());
var vy = String($("input[name='py']").map(function(){return $(this).val();}).get());
var vxArr = vx.split(",");
var vyArr = vy.split(",");
var lenArr = vxArr.length;
var isi = "";
for (i = 0; i < lenArr; i++) {
var koord = "X" + vxArr[i] + " " + "Y" + vyArr[i];
//alert (koord);
var isi = isi + ', ' + koord;
}
//alert (isi);
var lastChar = isi.substr(2); // => "1"
$("#koord").val(lastChar);
}
</script>
The result in textarea is
Image link https://postimg.cc/fJWHhxp9
What i'm expected is
+---------+---------+
| X Point | Y Point |
+---------+---------+
| 123 | 456 |
| 123 | 456 |
| 123 | 456 |
| 123 | 456 |
+---------+---------+
javascript jquery html
javascript jquery html
asked Jan 2 at 3:20
KusnadiKusnadi
245
245
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You have fixed length of inputs you can easily use array as values and generate the table out of it, instead of string you can keep that as an array and append the rows.
function next3() {
var vx = ($("input[name='px']").map(function() {
return $(this).val();
}).get());
var vy = ($("input[name='py']").map(function() {
return $(this).val();
}).get());
$('table tbody').html('');
vx.forEach((a, index) => {
if (a !== '' && vy[index] !== '') {
$('table tbody').append('<tr><td>' + a + '</td><td>' + vy[index] + '</td></tr>')
}
})
}table {
border: 1px solid black
}<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text"
name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<table>
<thead></thead>
<tbody></tbody>
</table>add a comment |
This should help you process the text:
const text = 'x123 y123, x234 y234, x345 y345';
// split text on commas ','
const splitTextArray = text.split(',');
console.log(splitTextArray);
// now map to objects you can reference
const textMapArray = splitTextArray.map(text => {
// now trim teading/trailing whitespace and split text on space
const splitText = text.trim().split(' ');
// save each string from the second char on (i.e. removes the x/y)
return {x: splitText[0].substring(1), y: splitText[1].substring(1) };
});
console.log(textMapArray);
i'm trying to change const text value into array but it show errorUncaught TypeError: text.split is not a function
– Kusnadi
Jan 2 at 4:23
splitis a string function, it won't on an array, it returns an array.
– Drew Reese
Jan 2 at 4:27
1
Ah, I think I may have misinterpreted your question. Seems you already got all your inputs, in an array, but then stringified it. Just Code has it I think.
– Drew Reese
Jan 2 at 4:39
Leaving here for someone to find in case it helps them.
– Drew Reese
Jan 2 at 6:18
add a comment |
try this i have made some changes
function next3() {
var vx = String($("input[name='px']").map(function () { return $(this).val(); }).get());
var vy = String($("input[name='py']").map(function () { return $(this).val(); }).get());
var vxArr = vx.split(",");
var vyArr = vy.split(",");
var lenArr = vxArr.length;
var isi = " "+"X Point" +" " + "Y Point"+'n';
//var isi = "";
for (i = 0; i < lenArr; i++) {
var koord = "" + vxArr[i] + " " + "" + vyArr[i];
//alert (koord);
var isi = isi + 'n' + koord;
}
//alert (isi);
var lastChar = isi.substr(1); // => "1"
$("#koord").val(lastChar);
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000857%2fhow-to-move-arrays-from-textarea-to-a-table-using-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have fixed length of inputs you can easily use array as values and generate the table out of it, instead of string you can keep that as an array and append the rows.
function next3() {
var vx = ($("input[name='px']").map(function() {
return $(this).val();
}).get());
var vy = ($("input[name='py']").map(function() {
return $(this).val();
}).get());
$('table tbody').html('');
vx.forEach((a, index) => {
if (a !== '' && vy[index] !== '') {
$('table tbody').append('<tr><td>' + a + '</td><td>' + vy[index] + '</td></tr>')
}
})
}table {
border: 1px solid black
}<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text"
name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<table>
<thead></thead>
<tbody></tbody>
</table>add a comment |
You have fixed length of inputs you can easily use array as values and generate the table out of it, instead of string you can keep that as an array and append the rows.
function next3() {
var vx = ($("input[name='px']").map(function() {
return $(this).val();
}).get());
var vy = ($("input[name='py']").map(function() {
return $(this).val();
}).get());
$('table tbody').html('');
vx.forEach((a, index) => {
if (a !== '' && vy[index] !== '') {
$('table tbody').append('<tr><td>' + a + '</td><td>' + vy[index] + '</td></tr>')
}
})
}table {
border: 1px solid black
}<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text"
name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<table>
<thead></thead>
<tbody></tbody>
</table>add a comment |
You have fixed length of inputs you can easily use array as values and generate the table out of it, instead of string you can keep that as an array and append the rows.
function next3() {
var vx = ($("input[name='px']").map(function() {
return $(this).val();
}).get());
var vy = ($("input[name='py']").map(function() {
return $(this).val();
}).get());
$('table tbody').html('');
vx.forEach((a, index) => {
if (a !== '' && vy[index] !== '') {
$('table tbody').append('<tr><td>' + a + '</td><td>' + vy[index] + '</td></tr>')
}
})
}table {
border: 1px solid black
}<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text"
name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<table>
<thead></thead>
<tbody></tbody>
</table>You have fixed length of inputs you can easily use array as values and generate the table out of it, instead of string you can keep that as an array and append the rows.
function next3() {
var vx = ($("input[name='px']").map(function() {
return $(this).val();
}).get());
var vy = ($("input[name='py']").map(function() {
return $(this).val();
}).get());
$('table tbody').html('');
vx.forEach((a, index) => {
if (a !== '' && vy[index] !== '') {
$('table tbody').append('<tr><td>' + a + '</td><td>' + vy[index] + '</td></tr>')
}
})
}table {
border: 1px solid black
}<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text"
name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<table>
<thead></thead>
<tbody></tbody>
</table>function next3() {
var vx = ($("input[name='px']").map(function() {
return $(this).val();
}).get());
var vy = ($("input[name='py']").map(function() {
return $(this).val();
}).get());
$('table tbody').html('');
vx.forEach((a, index) => {
if (a !== '' && vy[index] !== '') {
$('table tbody').append('<tr><td>' + a + '</td><td>' + vy[index] + '</td></tr>')
}
})
}table {
border: 1px solid black
}<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text"
name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<table>
<thead></thead>
<tbody></tbody>
</table>function next3() {
var vx = ($("input[name='px']").map(function() {
return $(this).val();
}).get());
var vy = ($("input[name='py']").map(function() {
return $(this).val();
}).get());
$('table tbody').html('');
vx.forEach((a, index) => {
if (a !== '' && vy[index] !== '') {
$('table tbody').append('<tr><td>' + a + '</td><td>' + vy[index] + '</td></tr>')
}
})
}table {
border: 1px solid black
}<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text"
name="py" value="" /><br> x <input type="text" name="px" value="" /> y <input type="text" name="py" value="" /><br>
<input type="button" value="next" onclick="next3();">
<textarea id="koord" value="" style="width:220px;"></textarea>
<table>
<thead></thead>
<tbody></tbody>
</table>answered Jan 2 at 4:23
Just codeJust code
10.4k53066
10.4k53066
add a comment |
add a comment |
This should help you process the text:
const text = 'x123 y123, x234 y234, x345 y345';
// split text on commas ','
const splitTextArray = text.split(',');
console.log(splitTextArray);
// now map to objects you can reference
const textMapArray = splitTextArray.map(text => {
// now trim teading/trailing whitespace and split text on space
const splitText = text.trim().split(' ');
// save each string from the second char on (i.e. removes the x/y)
return {x: splitText[0].substring(1), y: splitText[1].substring(1) };
});
console.log(textMapArray);
i'm trying to change const text value into array but it show errorUncaught TypeError: text.split is not a function
– Kusnadi
Jan 2 at 4:23
splitis a string function, it won't on an array, it returns an array.
– Drew Reese
Jan 2 at 4:27
1
Ah, I think I may have misinterpreted your question. Seems you already got all your inputs, in an array, but then stringified it. Just Code has it I think.
– Drew Reese
Jan 2 at 4:39
Leaving here for someone to find in case it helps them.
– Drew Reese
Jan 2 at 6:18
add a comment |
This should help you process the text:
const text = 'x123 y123, x234 y234, x345 y345';
// split text on commas ','
const splitTextArray = text.split(',');
console.log(splitTextArray);
// now map to objects you can reference
const textMapArray = splitTextArray.map(text => {
// now trim teading/trailing whitespace and split text on space
const splitText = text.trim().split(' ');
// save each string from the second char on (i.e. removes the x/y)
return {x: splitText[0].substring(1), y: splitText[1].substring(1) };
});
console.log(textMapArray);
i'm trying to change const text value into array but it show errorUncaught TypeError: text.split is not a function
– Kusnadi
Jan 2 at 4:23
splitis a string function, it won't on an array, it returns an array.
– Drew Reese
Jan 2 at 4:27
1
Ah, I think I may have misinterpreted your question. Seems you already got all your inputs, in an array, but then stringified it. Just Code has it I think.
– Drew Reese
Jan 2 at 4:39
Leaving here for someone to find in case it helps them.
– Drew Reese
Jan 2 at 6:18
add a comment |
This should help you process the text:
const text = 'x123 y123, x234 y234, x345 y345';
// split text on commas ','
const splitTextArray = text.split(',');
console.log(splitTextArray);
// now map to objects you can reference
const textMapArray = splitTextArray.map(text => {
// now trim teading/trailing whitespace and split text on space
const splitText = text.trim().split(' ');
// save each string from the second char on (i.e. removes the x/y)
return {x: splitText[0].substring(1), y: splitText[1].substring(1) };
});
console.log(textMapArray);This should help you process the text:
const text = 'x123 y123, x234 y234, x345 y345';
// split text on commas ','
const splitTextArray = text.split(',');
console.log(splitTextArray);
// now map to objects you can reference
const textMapArray = splitTextArray.map(text => {
// now trim teading/trailing whitespace and split text on space
const splitText = text.trim().split(' ');
// save each string from the second char on (i.e. removes the x/y)
return {x: splitText[0].substring(1), y: splitText[1].substring(1) };
});
console.log(textMapArray);const text = 'x123 y123, x234 y234, x345 y345';
// split text on commas ','
const splitTextArray = text.split(',');
console.log(splitTextArray);
// now map to objects you can reference
const textMapArray = splitTextArray.map(text => {
// now trim teading/trailing whitespace and split text on space
const splitText = text.trim().split(' ');
// save each string from the second char on (i.e. removes the x/y)
return {x: splitText[0].substring(1), y: splitText[1].substring(1) };
});
console.log(textMapArray);const text = 'x123 y123, x234 y234, x345 y345';
// split text on commas ','
const splitTextArray = text.split(',');
console.log(splitTextArray);
// now map to objects you can reference
const textMapArray = splitTextArray.map(text => {
// now trim teading/trailing whitespace and split text on space
const splitText = text.trim().split(' ');
// save each string from the second char on (i.e. removes the x/y)
return {x: splitText[0].substring(1), y: splitText[1].substring(1) };
});
console.log(textMapArray);answered Jan 2 at 3:45
Drew ReeseDrew Reese
950211
950211
i'm trying to change const text value into array but it show errorUncaught TypeError: text.split is not a function
– Kusnadi
Jan 2 at 4:23
splitis a string function, it won't on an array, it returns an array.
– Drew Reese
Jan 2 at 4:27
1
Ah, I think I may have misinterpreted your question. Seems you already got all your inputs, in an array, but then stringified it. Just Code has it I think.
– Drew Reese
Jan 2 at 4:39
Leaving here for someone to find in case it helps them.
– Drew Reese
Jan 2 at 6:18
add a comment |
i'm trying to change const text value into array but it show errorUncaught TypeError: text.split is not a function
– Kusnadi
Jan 2 at 4:23
splitis a string function, it won't on an array, it returns an array.
– Drew Reese
Jan 2 at 4:27
1
Ah, I think I may have misinterpreted your question. Seems you already got all your inputs, in an array, but then stringified it. Just Code has it I think.
– Drew Reese
Jan 2 at 4:39
Leaving here for someone to find in case it helps them.
– Drew Reese
Jan 2 at 6:18
i'm trying to change const text value into array but it show error
Uncaught TypeError: text.split is not a function– Kusnadi
Jan 2 at 4:23
i'm trying to change const text value into array but it show error
Uncaught TypeError: text.split is not a function– Kusnadi
Jan 2 at 4:23
split is a string function, it won't on an array, it returns an array.– Drew Reese
Jan 2 at 4:27
split is a string function, it won't on an array, it returns an array.– Drew Reese
Jan 2 at 4:27
1
1
Ah, I think I may have misinterpreted your question. Seems you already got all your inputs, in an array, but then stringified it. Just Code has it I think.
– Drew Reese
Jan 2 at 4:39
Ah, I think I may have misinterpreted your question. Seems you already got all your inputs, in an array, but then stringified it. Just Code has it I think.
– Drew Reese
Jan 2 at 4:39
Leaving here for someone to find in case it helps them.
– Drew Reese
Jan 2 at 6:18
Leaving here for someone to find in case it helps them.
– Drew Reese
Jan 2 at 6:18
add a comment |
try this i have made some changes
function next3() {
var vx = String($("input[name='px']").map(function () { return $(this).val(); }).get());
var vy = String($("input[name='py']").map(function () { return $(this).val(); }).get());
var vxArr = vx.split(",");
var vyArr = vy.split(",");
var lenArr = vxArr.length;
var isi = " "+"X Point" +" " + "Y Point"+'n';
//var isi = "";
for (i = 0; i < lenArr; i++) {
var koord = "" + vxArr[i] + " " + "" + vyArr[i];
//alert (koord);
var isi = isi + 'n' + koord;
}
//alert (isi);
var lastChar = isi.substr(1); // => "1"
$("#koord").val(lastChar);
}
add a comment |
try this i have made some changes
function next3() {
var vx = String($("input[name='px']").map(function () { return $(this).val(); }).get());
var vy = String($("input[name='py']").map(function () { return $(this).val(); }).get());
var vxArr = vx.split(",");
var vyArr = vy.split(",");
var lenArr = vxArr.length;
var isi = " "+"X Point" +" " + "Y Point"+'n';
//var isi = "";
for (i = 0; i < lenArr; i++) {
var koord = "" + vxArr[i] + " " + "" + vyArr[i];
//alert (koord);
var isi = isi + 'n' + koord;
}
//alert (isi);
var lastChar = isi.substr(1); // => "1"
$("#koord").val(lastChar);
}
add a comment |
try this i have made some changes
function next3() {
var vx = String($("input[name='px']").map(function () { return $(this).val(); }).get());
var vy = String($("input[name='py']").map(function () { return $(this).val(); }).get());
var vxArr = vx.split(",");
var vyArr = vy.split(",");
var lenArr = vxArr.length;
var isi = " "+"X Point" +" " + "Y Point"+'n';
//var isi = "";
for (i = 0; i < lenArr; i++) {
var koord = "" + vxArr[i] + " " + "" + vyArr[i];
//alert (koord);
var isi = isi + 'n' + koord;
}
//alert (isi);
var lastChar = isi.substr(1); // => "1"
$("#koord").val(lastChar);
}
try this i have made some changes
function next3() {
var vx = String($("input[name='px']").map(function () { return $(this).val(); }).get());
var vy = String($("input[name='py']").map(function () { return $(this).val(); }).get());
var vxArr = vx.split(",");
var vyArr = vy.split(",");
var lenArr = vxArr.length;
var isi = " "+"X Point" +" " + "Y Point"+'n';
//var isi = "";
for (i = 0; i < lenArr; i++) {
var koord = "" + vxArr[i] + " " + "" + vyArr[i];
//alert (koord);
var isi = isi + 'n' + koord;
}
//alert (isi);
var lastChar = isi.substr(1); // => "1"
$("#koord").val(lastChar);
}
answered Jan 2 at 4:29
ShubhamShubham
1825
1825
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000857%2fhow-to-move-arrays-from-textarea-to-a-table-using-javascript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown