Skip to content
Advertisement

two values for one name in input

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.

Advertisement

Answer

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”

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement