If I select multiple records with ckeck box i want ids on that selected recods
I have check box in data table if I select multiple first 3 records with check box after click on button I get ids like this id=1&id=2id=3
and I want ids number only and separate like this 1,2,3
function allAreEqual(aarray) {
if (!aarray.length) return false;
return aarray.reduce(function(a, b) {
return (a === b) ? a : (!b);
}) === aarray[0];
}
$(function() {
$('#create_challan').click(function() {
var allVals = ;
var saleid = ;
var buttonp = $(this);
buttonp.addClass('disabled');
buttonp.html(working);
$('input[name=checkboxlist]:checked').each(function() {
allVals.push($(this).val());
saleid.push($(this).attr('saleid'));
});
if (allAreEqual(saleid)) {
$.post('<?php echo base_url(); ?>index.php/' + user_type + '/' + module + '/create_invoice_pdf', {
<?php echo $this->security->get_csrf_token_name(); ?>: '<?php echo $this->security->get_csrf_hash(); ?>',
saleid: saleid[0],
val: allVals
},
function(data, status) {
window.open(base_url + 'invoices/' + data, '_blank');
window.focus();
location.reload();
});
} else {
bootbox.alert("<b><br><br>Selection Error!</b>");
buttonp.removeClass('disabled');
buttonp.html('Create Invoice');
}
});
});
jquery mysql sql ajax
add a comment |
I have check box in data table if I select multiple first 3 records with check box after click on button I get ids like this id=1&id=2id=3
and I want ids number only and separate like this 1,2,3
function allAreEqual(aarray) {
if (!aarray.length) return false;
return aarray.reduce(function(a, b) {
return (a === b) ? a : (!b);
}) === aarray[0];
}
$(function() {
$('#create_challan').click(function() {
var allVals = ;
var saleid = ;
var buttonp = $(this);
buttonp.addClass('disabled');
buttonp.html(working);
$('input[name=checkboxlist]:checked').each(function() {
allVals.push($(this).val());
saleid.push($(this).attr('saleid'));
});
if (allAreEqual(saleid)) {
$.post('<?php echo base_url(); ?>index.php/' + user_type + '/' + module + '/create_invoice_pdf', {
<?php echo $this->security->get_csrf_token_name(); ?>: '<?php echo $this->security->get_csrf_hash(); ?>',
saleid: saleid[0],
val: allVals
},
function(data, status) {
window.open(base_url + 'invoices/' + data, '_blank');
window.focus();
location.reload();
});
} else {
bootbox.alert("<b><br><br>Selection Error!</b>");
buttonp.removeClass('disabled');
buttonp.html('Create Invoice');
}
});
});
jquery mysql sql ajax
You mean on this propertyval: allVals
?
– DontVoteMeDown
Nov 20 '18 at 9:50
"I get ids like this id=1&id=2id=3"...where exactly are you seeing that value? If you're looking at the HTTP request body then that's expected - that's how you transmit values in a HTTP request. Although they will just over-write each other so you'd need to give them separate names, or use. More clarify over where you're seeing this info exactly would help a lot
– ADyson
Nov 20 '18 at 10:03
P.S. I notice that after your $.post request succeeds you are doing "location.reload()". Since you're going to just refresh the page immediately in this case, what was the reason for using AJAX? A normal form postback would be easier to handle, require less code and could have the same effect - make a request, load the required page afterwards. The whole purpose of AJAX is to allow you to stay on the same page. Redirecting the user immediately after AJAX completes entirely defeats the point of using it.
– ADyson
Nov 20 '18 at 10:05
add a comment |
I have check box in data table if I select multiple first 3 records with check box after click on button I get ids like this id=1&id=2id=3
and I want ids number only and separate like this 1,2,3
function allAreEqual(aarray) {
if (!aarray.length) return false;
return aarray.reduce(function(a, b) {
return (a === b) ? a : (!b);
}) === aarray[0];
}
$(function() {
$('#create_challan').click(function() {
var allVals = ;
var saleid = ;
var buttonp = $(this);
buttonp.addClass('disabled');
buttonp.html(working);
$('input[name=checkboxlist]:checked').each(function() {
allVals.push($(this).val());
saleid.push($(this).attr('saleid'));
});
if (allAreEqual(saleid)) {
$.post('<?php echo base_url(); ?>index.php/' + user_type + '/' + module + '/create_invoice_pdf', {
<?php echo $this->security->get_csrf_token_name(); ?>: '<?php echo $this->security->get_csrf_hash(); ?>',
saleid: saleid[0],
val: allVals
},
function(data, status) {
window.open(base_url + 'invoices/' + data, '_blank');
window.focus();
location.reload();
});
} else {
bootbox.alert("<b><br><br>Selection Error!</b>");
buttonp.removeClass('disabled');
buttonp.html('Create Invoice');
}
});
});
jquery mysql sql ajax
I have check box in data table if I select multiple first 3 records with check box after click on button I get ids like this id=1&id=2id=3
and I want ids number only and separate like this 1,2,3
function allAreEqual(aarray) {
if (!aarray.length) return false;
return aarray.reduce(function(a, b) {
return (a === b) ? a : (!b);
}) === aarray[0];
}
$(function() {
$('#create_challan').click(function() {
var allVals = ;
var saleid = ;
var buttonp = $(this);
buttonp.addClass('disabled');
buttonp.html(working);
$('input[name=checkboxlist]:checked').each(function() {
allVals.push($(this).val());
saleid.push($(this).attr('saleid'));
});
if (allAreEqual(saleid)) {
$.post('<?php echo base_url(); ?>index.php/' + user_type + '/' + module + '/create_invoice_pdf', {
<?php echo $this->security->get_csrf_token_name(); ?>: '<?php echo $this->security->get_csrf_hash(); ?>',
saleid: saleid[0],
val: allVals
},
function(data, status) {
window.open(base_url + 'invoices/' + data, '_blank');
window.focus();
location.reload();
});
} else {
bootbox.alert("<b><br><br>Selection Error!</b>");
buttonp.removeClass('disabled');
buttonp.html('Create Invoice');
}
});
});
jquery mysql sql ajax
jquery mysql sql ajax
edited Nov 20 '18 at 10:20


Krupesh Kotecha
2,05011134
2,05011134
asked Nov 20 '18 at 9:28
Shaikh Farhan SultanShaikh Farhan Sultan
208
208
You mean on this propertyval: allVals
?
– DontVoteMeDown
Nov 20 '18 at 9:50
"I get ids like this id=1&id=2id=3"...where exactly are you seeing that value? If you're looking at the HTTP request body then that's expected - that's how you transmit values in a HTTP request. Although they will just over-write each other so you'd need to give them separate names, or use. More clarify over where you're seeing this info exactly would help a lot
– ADyson
Nov 20 '18 at 10:03
P.S. I notice that after your $.post request succeeds you are doing "location.reload()". Since you're going to just refresh the page immediately in this case, what was the reason for using AJAX? A normal form postback would be easier to handle, require less code and could have the same effect - make a request, load the required page afterwards. The whole purpose of AJAX is to allow you to stay on the same page. Redirecting the user immediately after AJAX completes entirely defeats the point of using it.
– ADyson
Nov 20 '18 at 10:05
add a comment |
You mean on this propertyval: allVals
?
– DontVoteMeDown
Nov 20 '18 at 9:50
"I get ids like this id=1&id=2id=3"...where exactly are you seeing that value? If you're looking at the HTTP request body then that's expected - that's how you transmit values in a HTTP request. Although they will just over-write each other so you'd need to give them separate names, or use. More clarify over where you're seeing this info exactly would help a lot
– ADyson
Nov 20 '18 at 10:03
P.S. I notice that after your $.post request succeeds you are doing "location.reload()". Since you're going to just refresh the page immediately in this case, what was the reason for using AJAX? A normal form postback would be easier to handle, require less code and could have the same effect - make a request, load the required page afterwards. The whole purpose of AJAX is to allow you to stay on the same page. Redirecting the user immediately after AJAX completes entirely defeats the point of using it.
– ADyson
Nov 20 '18 at 10:05
You mean on this property
val: allVals
?– DontVoteMeDown
Nov 20 '18 at 9:50
You mean on this property
val: allVals
?– DontVoteMeDown
Nov 20 '18 at 9:50
"I get ids like this id=1&id=2id=3"...where exactly are you seeing that value? If you're looking at the HTTP request body then that's expected - that's how you transmit values in a HTTP request. Although they will just over-write each other so you'd need to give them separate names, or use
. More clarify over where you're seeing this info exactly would help a lot– ADyson
Nov 20 '18 at 10:03
"I get ids like this id=1&id=2id=3"...where exactly are you seeing that value? If you're looking at the HTTP request body then that's expected - that's how you transmit values in a HTTP request. Although they will just over-write each other so you'd need to give them separate names, or use
. More clarify over where you're seeing this info exactly would help a lot– ADyson
Nov 20 '18 at 10:03
P.S. I notice that after your $.post request succeeds you are doing "location.reload()". Since you're going to just refresh the page immediately in this case, what was the reason for using AJAX? A normal form postback would be easier to handle, require less code and could have the same effect - make a request, load the required page afterwards. The whole purpose of AJAX is to allow you to stay on the same page. Redirecting the user immediately after AJAX completes entirely defeats the point of using it.
– ADyson
Nov 20 '18 at 10:05
P.S. I notice that after your $.post request succeeds you are doing "location.reload()". Since you're going to just refresh the page immediately in this case, what was the reason for using AJAX? A normal form postback would be easier to handle, require less code and could have the same effect - make a request, load the required page afterwards. The whole purpose of AJAX is to allow you to stay on the same page. Redirecting the user immediately after AJAX completes entirely defeats the point of using it.
– ADyson
Nov 20 '18 at 10:05
add a comment |
1 Answer
1
active
oldest
votes
you can handle that on jquery level directly
for example:-
if you have 5 cells in one row
set one cell like
<tr>
<td class='idcontainer' data-id='myid'>any-other-data</td>
</tr>
the data-id
will store the id for every item in each row
on click of the submit
button
you need to apply forloop for each <tr>
find its child TD like $('td.idcontainer').data('id');
and store them in an array which is NOT LOCAL VARIABLE
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%2f53389908%2fif-i-select-multiple-records-with-ckeck-box-i-want-ids-on-that-selected-recods%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you can handle that on jquery level directly
for example:-
if you have 5 cells in one row
set one cell like
<tr>
<td class='idcontainer' data-id='myid'>any-other-data</td>
</tr>
the data-id
will store the id for every item in each row
on click of the submit
button
you need to apply forloop for each <tr>
find its child TD like $('td.idcontainer').data('id');
and store them in an array which is NOT LOCAL VARIABLE
add a comment |
you can handle that on jquery level directly
for example:-
if you have 5 cells in one row
set one cell like
<tr>
<td class='idcontainer' data-id='myid'>any-other-data</td>
</tr>
the data-id
will store the id for every item in each row
on click of the submit
button
you need to apply forloop for each <tr>
find its child TD like $('td.idcontainer').data('id');
and store them in an array which is NOT LOCAL VARIABLE
add a comment |
you can handle that on jquery level directly
for example:-
if you have 5 cells in one row
set one cell like
<tr>
<td class='idcontainer' data-id='myid'>any-other-data</td>
</tr>
the data-id
will store the id for every item in each row
on click of the submit
button
you need to apply forloop for each <tr>
find its child TD like $('td.idcontainer').data('id');
and store them in an array which is NOT LOCAL VARIABLE
you can handle that on jquery level directly
for example:-
if you have 5 cells in one row
set one cell like
<tr>
<td class='idcontainer' data-id='myid'>any-other-data</td>
</tr>
the data-id
will store the id for every item in each row
on click of the submit
button
you need to apply forloop for each <tr>
find its child TD like $('td.idcontainer').data('id');
and store them in an array which is NOT LOCAL VARIABLE
answered Nov 20 '18 at 12:12


Yash SoniYash Soni
47510
47510
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%2f53389908%2fif-i-select-multiple-records-with-ckeck-box-i-want-ids-on-that-selected-recods%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
You mean on this property
val: allVals
?– DontVoteMeDown
Nov 20 '18 at 9:50
"I get ids like this id=1&id=2id=3"...where exactly are you seeing that value? If you're looking at the HTTP request body then that's expected - that's how you transmit values in a HTTP request. Although they will just over-write each other so you'd need to give them separate names, or use
. More clarify over where you're seeing this info exactly would help a lot
– ADyson
Nov 20 '18 at 10:03
P.S. I notice that after your $.post request succeeds you are doing "location.reload()". Since you're going to just refresh the page immediately in this case, what was the reason for using AJAX? A normal form postback would be easier to handle, require less code and could have the same effect - make a request, load the required page afterwards. The whole purpose of AJAX is to allow you to stay on the same page. Redirecting the user immediately after AJAX completes entirely defeats the point of using it.
– ADyson
Nov 20 '18 at 10:05