views:

66

answers:

3

I have dynamically loaded the values of checkbox using php, n m using AJAX in that page to call the processing page.

<form name="form1" id="form1" action="javascript:wait1();getPass('go.php?**place**='+ document.form1.place.value);" method="post" enctype="multipart/form-data">


<input name="place[]" type="checkbox" value="<?=$ro['article_title']?>" /><?=$ro['article_title']?>

As the checkbox consists of arrays, I do not get the values.

Plz help..

Thanks in advance.

A: 

To quote the spec:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

So [ and ] are not valid inside the name attribute.

Marcel Korpel
But they are often used when you use PHP as server side language to indicate that an array of values should be created: http://php.net/manual/en/language.variables.external.php
Felix Kling
A: 

Use the "array style" to access the form's properties, like form1['place[]']. As this is a checkbox, several values can be selected and form1['place[]'] will return a node list. You could build the URL by traversing through the list:

var places = document.form1['place[]'];

var checked_places = [];
for (var i = 0, l = places.length; i < l; i++) {
    if (places[i].checked) {
        checked_places.push('place[]=' + places[i].value);
    }
}
var url = "go.php?" + checked_places.join('&');

See a live example: http://jsfiddle.net/jrYBz/1/

But why do it like that? As you are POSTing the form anyway, why not just read the values via $_POST on the server side?

Felix Kling
A: 

Thank u all for your concern!!!

I think I got the solution. :)

Anjali
Then please accept an answer to make your problem "solved". See ( http://stackoverflow.com/faq ). Welcome to Stackoverflow :)
edorian
I did it, thanks! :)
Anjali