Solved

js datatable, and checkbox

Posted on 2016-07-29
6
36 Views
Last Modified: 2016-08-30
https://jsfiddle.net/gyrocode/07Lrpqm7/

I use above datatable source code and when the submit button is clicked, it capture the value, but it shown
id=1, id=2, id=3 and etc.

I wonder how to capture them when I need to save those record into the ms sql database.
0
Comment
Question by:ITsolutionWizard
  • 4
  • 2
6 Comments
 
LVL 30

Accepted Solution

by:
Marco Gasi earned 500 total points (awarded by participants)
ID: 41735776
Do you mean this?
if (isset($_POST['id'])){
    $ids = $_POST['id'];
    foreach ($ids as $id){
        //do something with id values, i.e. build a query to insert values in the db
    } 
}

Open in new window

Keep in mind you have to remove the lines which are for testing only: don't serialize values and comment out the e.preventDefault so to allow the form to be submitted.
0
 

Author Comment

by:ITsolutionWizard
ID: 41740075
In your comment line, I need some helps how to capture the value.
0
 
LVL 30

Expert Comment

by:Marco Gasi
ID: 41740221
The value is in $id variable. How to capture it depends on what you want to do with the values: build an array to use in nother function, insert or update records in a database... Please, clarify this so I can suggest something
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:ITsolutionWizard
ID: 41751439
can you show me how to get array for $id ?
0
 
LVL 30

Expert Comment

by:Marco Gasi
ID: 41751663
In my code above, the array is in the variable $ids created from the global $_POST['id'].
But I suspect I misunderstood your question: what do you mean with
get array for $id
?
Are you talking about php or javascript? I thought you wanted php code since you said you have to insert data in mssql.
Can you explain exactly the workflow?
0
 
LVL 30

Expert Comment

by:Marco Gasi
ID: 41776005
Without any additional information, I think this comment perfectly answers to the question.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now