Hi,
I am having in a Trouble when working with dynamic checkboxes (i.e. checkboxes with the same name, e.g. <input type="checkbox" name = "check[]" value="dynamic integer value">)
I have submitted an HTML form (which contains dynamic textboxes and dynamic checkboxes with a Post Button(input type="button")) by using Ajax function. (onClick="retur n ajaxFunction(do cument.getEleme ntById('formid' ));")
In the ajax function, i have collected all form in a single javascript variable named 'formdata' as shown below :
------------
[CODE=javascript]for (i=0; i < theForm.length; i++)
{
if(theForm.elem ents[i].type == "text") { //Handle Textbox's
formdata = formdata + theForm.element s[i].name + "=" + escape(theForm. elements[i].value) + "&";
}
else if(theForm.elem ents[i].type == "checkbox" ) { //Handle checkbox's
formdata = formdata + theForm.element s[i].name + "=" + theForm.element s[i].value + "&";
}
[/CODE]
--------
i have passed this 'formdata' variable as an argument to the ajax function, which post all form data to a processing php page (i.e. process.php) and this page processes the data and send back HTTPResponse to the first page which contains that html form.
I am getting that all ajax Request and Response are working properly, but i m regularly receiving (in process.php) all checked and "UNCHECKED" both checkboxes' name and value in the Post data array, here i expect to receive ONLY CHECKED checkboxes in that Post data array.
I think, my javascript codes (shown above) is giving such unwanted result, Could you plz suggest me, how can i solve this problem ???
Thanks in advance,
Sunbin
I am having in a Trouble when working with dynamic checkboxes (i.e. checkboxes with the same name, e.g. <input type="checkbox" name = "check[]" value="dynamic integer value">)
I have submitted an HTML form (which contains dynamic textboxes and dynamic checkboxes with a Post Button(input type="button")) by using Ajax function. (onClick="retur n ajaxFunction(do cument.getEleme ntById('formid' ));")
In the ajax function, i have collected all form in a single javascript variable named 'formdata' as shown below :
------------
[CODE=javascript]for (i=0; i < theForm.length; i++)
{
if(theForm.elem ents[i].type == "text") { //Handle Textbox's
formdata = formdata + theForm.element s[i].name + "=" + escape(theForm. elements[i].value) + "&";
}
else if(theForm.elem ents[i].type == "checkbox" ) { //Handle checkbox's
formdata = formdata + theForm.element s[i].name + "=" + theForm.element s[i].value + "&";
}
[/CODE]
--------
i have passed this 'formdata' variable as an argument to the ajax function, which post all form data to a processing php page (i.e. process.php) and this page processes the data and send back HTTPResponse to the first page which contains that html form.
I am getting that all ajax Request and Response are working properly, but i m regularly receiving (in process.php) all checked and "UNCHECKED" both checkboxes' name and value in the Post data array, here i expect to receive ONLY CHECKED checkboxes in that Post data array.
I think, my javascript codes (shown above) is giving such unwanted result, Could you plz suggest me, how can i solve this problem ???
Thanks in advance,
Sunbin
Comment