Solved

js datatable, and checkbox

Posted on 2016-07-29
6
73 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 31

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
 
LVL 1

Author Comment

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

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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 1

Author Comment

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

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 31

Expert Comment

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

Featured Post

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

691 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