•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 455,968 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,746 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 3295 | Replies: 11
![]() |
| |
•
•
Join Date: Oct 2007
Posts: 34
Reputation:
Rep Power: 2
Solved Threads: 0
guys,
I can't seem to find any info on how to pass a list of checked checkboxes through POST method of ajax.
Unlike traditional forms, when you submit a button, a list of selected checkboxes with the same name will allow you to retrieve it at the server side (php in my case).
IS this the only way?
param = "selecteditem = " + document.myform.item[0].value;
param+ = "&selecteditem = " + document.myform.item[1].value;
param+ = "&selecteditem = " + document.myform.item[2].value;
Can there be any other ways so that i won't have to manually append each value to the same variable before posting the data?
I can't seem to find any info on how to pass a list of checked checkboxes through POST method of ajax.
Unlike traditional forms, when you submit a button, a list of selected checkboxes with the same name will allow you to retrieve it at the server side (php in my case).
IS this the only way?
param = "selecteditem = " + document.myform.item[0].value;
param+ = "&selecteditem = " + document.myform.item[1].value;
param+ = "&selecteditem = " + document.myform.item[2].value;
Can there be any other ways so that i won't have to manually append each value to the same variable before posting the data?
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 636
Reputation:
Rep Power: 3
Solved Threads: 71
> Can there be any other ways so that i won't have to manually append each value to the
> same variable before posting the data?
Not that I know of. You can of course write your own function 'serializeForm()' which would work in all cases by returning a string equivalent of the form values.
Or use one of the many libraries out there which could simplify this task for you.
> same variable before posting the data?
Not that I know of. You can of course write your own function 'serializeForm()' which would work in all cases by returning a string equivalent of the form values.
Or use one of the many libraries out there which could simplify this task for you.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 636
Reputation:
Rep Power: 3
Solved Threads: 71
•
•
Join Date: Oct 2007
Posts: 34
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
i made a ajax and php script that will post the value of only checked boxes into an array that can be read by php.(i was really bored) what are you doing with the values after they are submitted so i can finish the code?
well, basically i'll be using it to delete the selected items from a table. Did you manage to do it without appending it with javascript?
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 636
Reputation:
Rep Power: 3
Solved Threads: 71
sorry, i couldn't do it without appending the values. i tried 2 different ways and both of the failed with javascript errors. i made it so you wouldn't have to append each one manually. if you add a checkbox the script will not have to adjusted at all, it would still work. i will post the code if you need me too unless you have your own.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Help needed working with prototype.js and php (JavaScript / DHTML / AJAX)
- post priveiw popup (DaniWeb Community Feedback)
- Question - ASP + Ajax (ASP)
- AJAX : Am i right with the concept? (JavaScript / DHTML / AJAX)
- php coding for checkboxes (PHP)
- Servlet does not receive all post data (Java)
- How Do We Make A Form Without Post Or Get (PHP)
- New Ajax Tutorial (IT Technologies and Trends)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Loading External Website pages using ajax
- Next Thread: JS: automatic calculate without click any button



Hybrid Mode