Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

two values for one name in input

Tags:

html

php

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.

like image 393
Luis Avatar asked Aug 04 '10 15:08

Luis


1 Answers

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"

like image 132
sberry Avatar answered Oct 08 '22 11:10

sberry