Is it possible to pass 2 values for a radio button? I need to write two values to two different columns in a table but the values of the radio button are related.
So, for the radio button, they have a show id and title id. Both need to be written to a column in another table.
How do I pass both ids from the same radio button value? Or what would be an alternative?
Well, radio buttons can have a value attribute just like most other form elements. You can do something as simple as this:
<input type="radio" name="thefields" value="show_id1,title_id1">
<input type="radio" name="thefields" value="show_id2,title_id2">
etc
Then when you process the submit, you can do:
$fields = explode(',', Input::get('thefields'));
if (count($fields) == 2)
{
// carry on here...
$show_id = intval($fields[0]);
$title_id = intval($fields[1]);
// etc...
}
else
{
// handle error
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community