I need to retain the dropdown list value after post submit where the values for the dropdown list are read populated from an array, not hardcoded.
This is my code for populating the dropdown list:
<?php
foreach ($catalogueArray as $cataloguePDFName) {
echo '<option value="'. $cataloguePDFName . '">' . $cataloguePDFName . '<option />';
}
?>
<label>Template</label>
<select name="templatepdfs" />
<?php
foreach ($templateArray as $templatePDFName) {
echo '<option value="'. $templatePDFName . '">' . $templatePDFName . '<option />';
}
?>
<input type="submit" name="submit" value="Submit">
Can somebody guide me how can I echo the selected dropdown value. I have seen examples how it can be done when the values are hardcoded, but for some reason im running into errors when trying for my dynamic dropdown list. Any help would be appreciated.
Thanks
Did you mean something like this?
Put your code in :
OR: