如何检索PHP POST中的自定义HTML属性? [英] How to retrieve custom html attribute in php POST?

查看:70
本文介绍了如何检索PHP POST中的自定义HTML属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义复选框,它在Div中创建

$ p $ < div class =zsname =toggle state =onid =zs>< / div>

复选框已打开/关闭,状态属性在点击开启/关闭时发生变化。 p>

div放置在提交中,但我不知道如何从php获取$ _POST ['toggle']以接收属性state

解决方案

浏览器只会通过输入选择标签与表单提交,而不是 div 。这听起来像你可能想要将你的价值存储在隐藏的输入中,IE:

 < input type ='hidden'name ='toggle'value ='on'/> 

然后添加到您已经使用的任何javascript,以适当地设置值。


I have a custom Checkbox its made in a Div

<div class="zs" name="toggle" state="on" id="zs"></div>

The checkbox has toggle on/off and the state attribute changes on click to on/off.

The div is placed in a for submittion but I dont know how to get $_POST['toggle'] from php to receive the attribute "state"

解决方案

The browser is only going to send through input and select tags with the form submission, not div. It sounds like you might want to store your value in a hidden input, IE:

<input type='hidden' name='toggle' value='on' />

Then add to whatever javascript you're already using to set the value appropriately.

这篇关于如何检索PHP POST中的自定义HTML属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆