[UPHPU] $_POST arrays

TJ Hunter tjhunter at gmail.com
Tue Sep 20 14:53:51 MDT 2005


On 9/20/05, Scott Hill <llihttocs at gmail.com> wrote:
> What I get in the process.php is the checkitems array with ONLY the check
> values. The enteredvalues array has an entry for every item even if it is
> blank.
>
> How can I make the second array behave like the first?
> or
> Is there a better way to do it?
>
> (Sorry for the long posting)
>

I think this is a browser issue. If a checkbox is not checked, the
browser won't post that variable back at all, where as it will post an
input-text back even if it is empty.

What you could do is this:

<form action="process.php" method="post">
<ul>
<li><input type="checkbox" name="checkeditems[1]" value="1" /><input
type="text" name="enteredvalues[1]" value="" /></li>
<li><input type="checkbox" name="checkeditems[2]" value="2" /><input
type="text" name="enteredvalues[2]" value="" /></li>
<li><input type="checkbox" name="checkeditems[3]" value="3" /><input
type="text" name="enteredvalues[3]" value="" /></li>
<li><input type="checkbox" name="checkeditems[4]" value="4" /><input
type="text" name="enteredvalues[4]" value="" /></li>
</ul>

so at least you can match the checkboxes and input-text's together using a key.




More information about the UPHPU mailing list