Displaying validated entries and/or recordset values BUT in a dynamic drop-down menu?
When adding the WA Server Validations to any form, it quickly becomes apparent that when you submit the form, and validation fails, all of your form values are wiped and the user has to start the entire form again. I'm not sure why that is, but it's the current state of play.
So, you have to manually add the ValidatedField data as the default value for every field in your form, like so:
<input type="text" class="form-control" name="FirstName" id="FirstName" placeholder="First name" maxlength="30" value="<?php echo(ValidatedField("healthscreeningform_984","FirstName")) ?>" required>
But what if your form is populated by data from a recordset? Well, you have to double up the default value to include the ValidatedField data AND the Recordset data, like so:
<input type="text" class="form-control" name="FirstName" id="FirstName" placeholder="First name" maxlength="30" value="<?php echo(isset($_GET['v'])?ValidatedField("healthscreeningform_984","FirstName"):$rsEDITFORM->getColumnVal("SMCformFIRST")) ?>" required>
This is incredbily time consuming to configure, but it's working.
My problem is how to handle dynamic drop-down menus? At the moment I have the option values within a repeat region, like so...
<?php
while(!$rsCOUNTRIES->atEnd()) { //dyn select
?>
<option value="<?php echo($rsCOUNTRIES->getColumnVal("SMCcountryID")); ?>"<?php if (!(strcmp($rsCOUNTRIES->getColumnVal("SMCcountryID"), (ValidatedField("healthscreeningform_984","Country"))))) {echo "selected=\"selected\"";} ?>><?php echo($rsCOUNTRIES->getColumnVal("SMCcountryNAME")); ?></option>
<?php
$rsCOUNTRIES->moveNext();
} //dyn select
$rsCOUNTRIES->moveFirst();
?>
Two things this isn't doing. It's not displaying the Country from the Recordset ($rsEDITFORM), and it's also not remembering the ValidatedField data so the Country menu is wiped blank every time validation fails.
One thing that might be complicating this is that I have a sub-dependent State field which changes depending on what the user selects from the Country drop-down.
What is wrong with my code that it's not remembering the Country selection by the user, and how do I, like my other fields, also incorporate the Recordset country and region data?
This can be viewed at:
www.sportsmedicalcertificates.com/health-screening-form.php?tab1=1
Thank you
NJ