2

When a process changed required me to change a radio button field, to a checkbox to allow multiple selections, I made the following change to my html:

    <input type='checkbox' name='ptype[]' value='1'> Jail/not sentenced</br>
    <input type='checkbox' name='ptype[]' value='2'> Jail/Sentenced</br>
    <input type='checkbox' name='ptype[]' value='3'> State/DOC</br>
    <input type='checkbox' name='ptype[]' value='4'> ICE/US Marshall</br>
    <input type='checkbox' name='ptype[]' value='5'> 7x/wardens Agree</br>

When making ptype an array to handle multiple selections, I am finding my $_POST variable missing a key. If I try to revert ptype to a radio button and handle only one value, I don't get any error/warning.

I've checked Firebug, and when ptype[] is set, one of my $_POST variables is not relayed. I know the max post variable is not an issue, as I only have 52 post variables on my form.

I don't know if it's relevant, but this field is never coming through:

    <input type='radio' name='wc' value='1'> Yes
    <input type='radio' name='wc' value='0'> No

   Notice: Undefined index: wc in C:\inetpub\wwwroot\internal_tools\include\consults\consult_utilities.php on line 53 

Any help would be greatly appreciated.

EDIT: As requested, my form.

EDIT 2: Firebug POST variables

EDIT 3: Added line 53:

$data['workers_comp']           = $_POST['wc'];
4

1 回答 1

1

可能您没有为单选按钮选择选项,wc因此未提交变量。

您应该将 PHP 代码更改为:

$wc = isset($_POST["wc"]) ? $_POST["ws"] : "0";

或者,正如我已经在评论中建议的那样,您validateFrm在提交表单时调用的 javascript 方法存在问题。

于 2013-08-16T13:38:10.237 回答