Pass recordset value to hidden form field based on value of another field
I have a data insert form and it includes a radio button field to select a user from a recordset so that it will populate the database column with their UserID. However, I also need to get another column value (randomString) for the same user to populate a hidden field, so this would be based on the selection made with the radio button. This is the radio button and hidden field code:
<div class="radio">
<p>Add details to the following adviser's record:</p>
<?php
$wa_startindex = 0;
while(!$rsUsers->atEnd()) {
$wa_startindex = $rsUsers->Index;
?>
<label>
<input type="radio" name="UserID" id="UserID" value="<?php echo($rsUsers->getColumnVal("ID")); ?>">
<?php echo($rsUsers->getColumnVal("display_name")); ?></label><input type="hidden" name="randomString" id="randomString" value="<?php echo($rsUsers->getColumnVal("randomString")); ?>">
<br>
<?php
$rsUsers->moveNext();
}
$rsUsers->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?>
</div>
I'm sure I've done this before but can't remember how I did it! Can you help?