Hi Guys,
Could someone please help. I have jused a javascript to collect an array of items selected by a user.How can I send this array to another page for processing. More specifically, How can I pass this array to a php code to iterate though the items in the array.
Thanks for your help.
OJ
[SOLVED] Moving an array of selected values to the next page
Moderator: General Moderators
Code: Select all
<script language = "e;Javascript"e;>
function getAllCheckedBoxes(){
var checkbox_choices = 0;
var selectedArray= new Array();
// Loop from zero to the one minus the number of checkbox button selections
for (counter = 0; counter < checkbox_form.checkbox.length; counter++)
{
// If a checkbox has been selected it will return true
// (If not it will return false)
if (checkbox_form.checkboxїcounter].checked)
{
selectedArray.push(checkbox_form.checkboxїcounter].value);
checkbox_choices = checkbox_choices + 1; }
}
return selectedArray;
}
}
</script>Code: Select all
<form method="e;get"e; action="e;Show.php"e;
onsubmit="e;return checkbox_checker()"e; name="e;checkbox_form"e;>
<input type="e;checkbox"e; value="e;1"e; name="e;checkbox"e;>Hank Aaron<br>
<input type="e;checkbox"e; value="e;2"e; name="e;checkbox"e;>Ted Williams<br>
<input type="e;checkbox"e; value="e;3"e; name="e;checkbox"e;>Hank Greenberg<br>
</form>Then I want to pass the array returned from the javascript to a php function that will do the following:
Code: Select all
for($i=0;$i<selectedArray.length;$i++){
print(selectedArrayї$i]);
}I will appreciate if someone can help me.Is it possible to pass the array returned by javascript to php session?. If so how can I do that
Thanks
feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]Thanks for your response. If you look at the code, all the check boxes have the same name but different values. I tried that approach and I am only able to fetch the last value.
The post will look like:
checkbox=1&checkbox=2&checkbox=3
Therefore, I will only get Checkbox=3 on the next page.
I still need more help.
Thanks
The post will look like:
checkbox=1&checkbox=2&checkbox=3
Therefore, I will only get Checkbox=3 on the next page.
I still need more help.
Thanks