Jump to content

Html Form: Checkbox And Text Inputs


nodirtyrockstar

Recommended Posts

I have a table contained by a form. Each row of the table contains the following data cells:

<td>
<input type='text' name='cart[ccr-01-002]' size='2' />
</td>
<td>
<input type='checkbox' name='delete[ccr-01-002]' />
</td>

 

Rather than returning whether or not the checkbox is checked (such as ON or OFF), it is instead returning the value of the text input field. Here is how I am trying to reference it:

 

var_dump($_POST['delete']);

 

This prints out the string contents of the text fields instead of ON or OFF. Is it possible (without having to put the checkbox into its own form) to reference the checkbox as a separate entity from the text input? I would like to reference $_POST['cart'], and not have it affect $_POST['delete'].

 

Please let me know if you need any other information!

Link to comment
https://forums.phpfreaks.com/topic/269962-html-form-checkbox-and-text-inputs/
Share on other sites

Give both of them a value.

 

Since they have different names, they will have different values. What you're describing doesn't make any sense, and you haven't shown any proof of it.

 

Edit: Do you think 'ccr-01-002' is the value? It's not. It's an array key. What you get when you print_r or var_dump your arrays is a bunch of keys with empty values.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.