输入中的一个名称的两个值 [英] two values for one name in input
问题描述
< p $>我有一个输入(类型无线电),我想插入它的2个值,就像这样: input type =radioname =namevalue1 =value1value2 =value2/>
并且在绘制每个值后用PHP分隔。
有办法做到这一点? (不,我不想插入type =hidden的输入)
好吧,不是我会这么做的方式,但是您可以为您的值使用分隔符
< input type =radiovalue =Value1 | Value2name =two_values/>
然后,在PHP中,只需 list($ value1,$ value2)= explode('|',$ _POST ['two_values']);
编辑
正如@ user387302所说,你显然限于没有包含分隔符的任何值,例如 value =One | PipedVariable | andAnother
不能用于提取两个值One | PipedValue和andAnother
I have one input (type radio) that I want to insert it 2 values, something like that:
<input type="radio" name="name" value1="value1" value2="value2" />
And after draw each value seperated with PHP.
There is a way to do it? (And no.. I dont want to insert input with type="hidden")
Thank you.
Well, not the way I would do it, but you could use a delimiter for your value(s)
<input type="radio" value="Value1|Value2" name="two_values" />
Then, in PHP, just list($value1,$value2) = explode('|', $_POST['two_values']);
EDIT
As @user387302 said, you would obviously be limited to not having any values containing your delimiter, for example value="One|PipedVariable|andAnother"
would not work to extract two values of "One|PipedValue" and "andAnother"
这篇关于输入中的一个名称的两个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!