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?

Recommended Answers

All 11 Replies

does it have the use ajax?

does it have the use ajax?

absolutely, because i don't want my page to refresh.

> 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 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?

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?:|

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.

kkeith29, well its good to share it for others to refer next time ;)

anyone can help me that how to pass value of selected dropdown list from one page to another page in AJAX

could you go into more detail? i can help but i need to know

there is a html page where dropdown box(combo box) is display i just select a value nad want to send it in PHP page then how it'll be pass

what do you want to do with it when its submitted to the php page?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.