RE: [PHP] radio groups in looped form
| From: | Rudolf Visagie | Date: | Thu, 12 Apr 2001 08:56:57 +0000 |
| Subject: | RE: [PHP] radio groups in looped form | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-48271@lists.php.net to get a copy of this message | ||
Hi Peter
I use this function in one of my scripts. Maybe you can get a few ideas from
it.
function WriteRadio ($FieldNo, $NOptions, $OptionValue, $Option,
$SelectedValue, $NullValue) {
/*
The Radio function writes a group of HTML INPUT radio buttons.
$OptionValue = input value
$Option = the option wording in the radio button group
$SelectedValue = the option value that is currently checked
$NullValue = the first option is empty if true (returns all
records for queries)
*/
if ($NullValue) {
echo "<INPUT type='radio' value=''
name='f[".$FieldNo."]'>
N/A";
}
for ($i = 0; $i <= $NOptions[$FieldNo]; $i++) {
if ($OptionValue[$FieldNo][$i] == $SelectedValue) {
echo "<INPUT type='radio'
value='".$OptionValue[$FieldNo][$i]."'
name='f[".$FieldNo."]' checked>
".$Option[$FieldNo][$i];
} else {
echo "<INPUT type='radio'
value='".$OptionValue[$FieldNo][$i]."'
name='f[".$FieldNo."]'>
".$Option[$FieldNo][$i];
}
}
return 0;
}
Rudolf Visagie
rudolf@qedi.co.za
-----Original Message-----
From: Peter Houchin [mailto:peterh@vfsa.com.au]
Sent: 12 April 2001 01:33
To: Php-General@Lists. Php. Net
Subject: [PHP] radio groups in looped form
hiya,
I have a script that repeats a form x number of times depending on how many
records there are, what's happening is when i go to update my radio buttons
it sees every radio button on the page as the ONE group when really it's x
number of groups (again depending on how many records there are)
How can i differ between raido groups with out having to get the name
changed for every record after the 1st one?
Peter Houchin
peterh@sunrentals.com.au
=========================================================
_____ __ /\
/_/_/_\ / |_/ \
/_/_/_ __ __ __ __ / \
\_/_/_\ /_/ /_/ /_/ /_/ \ _ /
___\_\_\/ /_/_/_/ /_//\/_/ \_/ \/\_/
\_//_/_/ /_/_/_/ /_/ \/_/ v
________ ________________________________________
/_/_/_/_/ /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
/_/_ _/_/ ______ __ __ /_/ ____ __ ______
/_/_/_/_/ /_/_/_/ /_/ /_/ /_/ /_/\_\ /_/ /_/_/_/
/_/ \_\ /_/ _/ /_//\/_/ /_/ /_/__\_\ /_/___ _\_\_\
/_/ \_\/_/_/_/ /_/ \/_/ /_/ /_/ \_\/_/_/_//_/_/_/
=========================================================
Telephone : (03) 9329 1455 Facsimile : (03) 9329 6755
************* We rent the dot in .COM! **************