Repeating Tables & Radio (group) buttons
I've created a repeating table that returns images belonging to a logged in user.
Each row features a check box and radio button which is used to select which images are active and the radio to assign a single image as the primary image. I'm using WA update multiple records to achieve this.
The checkboxes work fine, however the radio button is partially working. Unfortunately it is not allowing a single selection as you would expect in a radio group. They are behaving as checkboxes.
Heres the form code:
<form name="ManageUsrImgFrm" method="post" action="<?php echo (htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES)); ?>" >
<table width="100%" border="1" cellspacing="2" cellpadding="2">
<tr>
<th scope="col" width="180px">Thumbnail</th>
<th scope="col">Tag</th>
<th scope="col">Active</th>
<th scope="col">Amend</th>
<th scope="col">Delete</th>
<th scope="col">Primary</th>
</tr>
<?php do { ?>
<tr>
<?php
// RepeatSelectionCounter_1 Begin Loop
$RepeatSelectionCounter_1_IterationsRemaining = $RepeatSelectionCounter_1_Iterations;
while($RepeatSelectionCounter_1_IterationsRemaining--){
if($RepeatSelectionCounterBasedLooping_1 || $row_rsGetUser){
?>
<th scope="row"><?php
if(TRUE){ // Begin Cached Resized Image: ImageCacheInstance_1433274395061
ob_start();
?>
<img name="ShowThumbnail" src="<?php echo $row_rsGetUser['PicImageFolder']; ?><?php echo $row_rsGetUser['PicImageName']; ?>" width="180" height="100" alt="">
<?php
echo(getCachedResizedImageHTML(ob_get_clean(), "../image_cache", "crop", "", false));
} // End Cached Resized Image: ImageCacheInstance_1433274395061
?></th>
<td>Name</td>
<td><input type="hidden" name="WADA_RepeatID_PicID_<?php echo $RepeatSelectionCounter_1; ?>" id="WADA_RepeatID_PicID_<?php echo $RepeatSelectionCounter_1; ?>" value="<?php echo $row_rsGetUser["PicID"]; ?>" />
<input <?php if (!(strcmp($row_rsGetUser['PicImageActive'],1))) {echo "checked=\"checked\"";} ?> name="UsrImgActive_<?php echo $RepeatSelectionCounter_1; ?>" type="checkbox" id="checkbox_<?php echo $RepeatSelectionCounter_1; ?>" value="1" ></td>
<td>Amend</td>
<td>Delete</td>
<td><input <?php if (!(strcmp($row_rsGetUser['PicImageMain'],"1"))) {echo "checked=\"checked\"";} ?> name="UsrImgPrime_<?php echo $RepeatSelectionCounter_1; ?>" type="radio" id="UsrImgPrime_<?php echo $RepeatSelectionCounter_1; ?>" value="1">
<?php
} // RepeatSelectionCounter_1 Begin Alternate Content
else{
?>
<td>No records match your request.</td>
<?php } // RepeatSelectionCounter_1 End Alternate Content
if(!$RepeatSelectionCounterBasedLooping_1 && $RepeatSelectionCounter_1_IterationsRemaining != 0){
if(!$row_rsGetUser && $RepeatSelectionCounter_1_Iterations == -1){$RepeatSelectionCounter_1_IterationsRemaining = 0;}
$row_rsGetUser = mysql_fetch_assoc($rsGetUser);
}
$RepeatSelectionCounter_1++;
} // RepeatSelectionCounter_1 End Loop
?>
</tr>
<?php } while ($row_rsGetUser = mysql_fetch_assoc($rsGetUser)); ?>
</table>
<p> </p>
<p> </p>
<input name="BtnPrimeImg" type="submit" value="Update">
<input name="UsrImgPrimeDate" type="hidden">
A normal radio group share the same input name so only one can be selected, if i do the same here it behaves as a group but changes are not saved and returned when the page is refreshed.
Update: so i found this; http://www.webassist.com/forums/posts.php?id=31138
Resolved:
I've settled for using a second record update behaviour to post the selected value in. I can then call it through a recordset.
I seemed to have simplified the problem and solution!
Just need to tweak the following to return the selected option button when page is refreshed - it currently returns nothing!
<input <?php if (!(strcmp($row_rsGetUser['PicImagePrime'],1))) {echo "checked=\"checked\"";} ?> type="radio" id="UsrImgPrime_<?php echo $row_rsGetUser['PicID']; ?>" name="UsrImgPrime" value="<?php echo $row_rsGetUser['PicID']; ?>">
Any ideas anyone?