Saturday, 31 August 2013

Foreach only prints one value from array when using Ajax and onsubmitForm

Foreach only prints one value from array when using Ajax and onsubmitForm

I'm using Ajax to POST a value to another page without refreshing the
current page, but when I add the form HTML to the Foreach argument, it
will only print out one of the first of the 50 array values.
If I don't include onsubmit='return SubmitFor();' the Ajax script won't
run on click, but the Foreach will print all of the array values.
Here is my Foreach:
foreach ($Results as $arrResult) {
$IDstring = $arrResult['id_str'] ;
print("<form id='RT' onsubmit='return submitForm();'><input
type='hidden' name='id' value=$IDstring><input type='submit'
value='RT'></form></div>");
}
So I'm assuming that this onsubmit='return SubmitFor();' is the issue? Is
it not possible to include that with a PHP foreach? How can I get print to
print all the array values instead of the first result only?

No comments:

Post a Comment