SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Function Help
-
Dec 13, 2009, 22:02 #1
Function Help
Hello,
I have a radio function I created.
<?php
function questionnaire($name, $choices, $q)
{
// setting up the select option
foreach ($choices as $c):
$radioSelected = ($c == $q ? 'checked="checked"' : "");
$radio .=<<<EOD
<input name="$name" type="radio" value="$c" />
<input name="work" type="hidden" value="testing" />
EOD;
endforeach;
return $radio;
}
?>
$choices = Array("items1", items2", etcc..);
I call it like $trac = questionnaire("Tracheostomy", $choices, $row_nameInformation['Tracheostomy']);
When I preview the source on the page the html rendered looks correctly.
But when I post to an update_Page.php I can't get the post to work. When I check for $name or the hidden "work" as a test it comes up blank each time. I have a dropdown select menu, a yes no menu which I have set up functions the same way and they all work.
Any help as to what I am missing with the radio?/
Thanks
-
Dec 13, 2009, 22:14 #2
I got it thanks.
-
Dec 13, 2009, 23:01 #3
- Join Date
- Sep 2003
- Location
- Carson City, NV
- Posts
- 557
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Glad you got it, but can you post what you found, so that others might learn?
Making a difference, one little psychotic episode at a time
Geek Cave Creations
Beta testers needed for pChat
Dave's Gallery
-
Dec 13, 2009, 23:11 #4
-
Dec 14, 2009, 12:58 #5
Well I was hoping to just delete the thread because the function was working I just forgot to put inside the form. So naturally when I hit submit it would make sense nothing would post. So if someone comes across this post looking for a function for multiple radio button(s), it works just put inside the form. Have a good laugh
Function
<?php
function questionnaire($name, $choices, $q)
{
// setting up the select option
foreach ($choices as $c):
$radioSelected = ($c == $q ? 'checked="checked"' : "");
$radio .=<<<EOD
<input name="$name" type="radio" value="$c" />
<input name="work" type="hidden" value="testing" />
EOD;
endforeach;
return $radio;
}
?>
How use it in php page:
$var = questionnaire("Tracheostomy", $var(this one is an array for me), $var);
Bookmarks