User Name Password Register
DaniWeb IT Discussion Community
All
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 391,768 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,152 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: 2634 | Replies: 11
Reply
Join Date: Oct 2007
Posts: 34
Reputation: adrive is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
adrive adrive is offline Offline
Light Poster

ajax POST checkboxes

  #1  
Nov 23rd, 2007
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 536
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 54
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Posting Pro

Re: ajax POST checkboxes

  #2  
Nov 23rd, 2007
does it have the use ajax?
Reply With Quote  
Join Date: Oct 2007
Posts: 34
Reputation: adrive is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
adrive adrive is offline Offline
Light Poster

Re: ajax POST checkboxes

  #3  
Nov 23rd, 2007
Originally Posted by kkeith29 View Post
does it have the use ajax?


absolutely, because i don't want my page to refresh.
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 6,774
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 330
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: ajax POST checkboxes

  #4  
Nov 24th, 2007
> 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.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 536
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 54
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Posting Pro

Re: ajax POST checkboxes

  #5  
Nov 24th, 2007
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?
Reply With Quote  
Join Date: Oct 2007
Posts: 34
Reputation: adrive is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
adrive adrive is offline Offline
Light Poster

Re: ajax POST checkboxes

  #6  
Nov 24th, 2007
Originally Posted by kkeith29 View Post
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?
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 536
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 54
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Posting Pro

Re: ajax POST checkboxes

  #7  
Nov 24th, 2007
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.
Reply With Quote  
Join Date: Oct 2007
Posts: 34
Reputation: adrive is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
adrive adrive is offline Offline
Light Poster

Re: ajax POST checkboxes

  #8  
Nov 24th, 2007
kkeith29, well its good to share it for others to refer next time
Reply With Quote  
Join Date: Nov 2007
Posts: 2
Reputation: AnnuPriya is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
AnnuPriya AnnuPriya is offline Offline
Newbie Poster

Re: ajax POST checkboxes

  #9  
Nov 26th, 2007
anyone can help me that how to pass value of selected dropdown list from one page to another page in AJAX
Last edited by AnnuPriya : Nov 26th, 2007 at 12:23 am.
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 536
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 54
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Posting Pro

Re: ajax POST checkboxes

  #10  
Nov 26th, 2007
could you go into more detail? i can help but i need to know
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 4:32 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC