dpdhnd3577 2012-12-20 09:23
浏览 147
已采纳

如何使单选按钮返回布尔值true / false而不是on / off

I want that my radio buttons return me a Boolean value true or false instade of on/off

So I pass the true/false in the value of the input :

<label>Male
   <input type="radio" name="IsMale" value="true" />
</label> 
<label>Female
   <input type="radio" name="IsMale" value="false" />
</label>

but it returns me a true/false in a text format. Please masters how could I get them in a booleen format ?

More details : In fact I need to store my $_POST array in a file.txt, and for my radio button I need to store for example :

array ( "IsMale" => true );

and not :

array ( "IsMale" => "true" );
  • 写回答

2条回答 默认 最新

  • dongmao7195 2012-12-20 09:25
    关注

    You'll have to check the data and modify it.

    if(isset($_POST['SubmitButton'])) { 
    
      $_POST['IsMale'] = $_POST['IsMale'] == 'true' ? true : false;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿