我希望我的选择框在提交表单后保留数据。以下是代码。
foreach ($data as $row) {
$selected = '';
if (isset($_SESSION['classes']) && !empty($_SESSION['classes'])) {
global $selected;
$sessions = $_SESSION['classes'];
$cls_val = $row['id'];
if ($sessions == $cls_val) {
$selected= "selected";
echo $selected;
}
}
$html.= '<option $selected value="'.$row['id'].'">'.Purifier($cls_full_data).'</option>';
}
echo '<select name="class_id" id="class_id" class="form-control form-control-sm font-label">'.$html.'</select>';
echo '<br>';
代码显示下拉列表没有任何问题,但是,我无法在提交后获取所选值。
答案 0 :(得分:1)
这看起来好多了。
blobService.getBlobToText(container, blobname, function(error, text){
if(error){
console.error(error);
res.status(500).send('Fail to download blob');
} else {
var data = JSON.parse(text);
res.status(200).send('Filtered Data you want to send back');
}
});
答案 1 :(得分:0)
将您的代码更改为:
foreach ($data as $row) {
$selected = '';
if (isset($_SESSION['classes']) && !empty($_SESSION['classes'])) {
global $selected;
$sessions = $_SESSION['classes'];
$cls_val = $row['id'];
if ($sessions == $cls_val) {
$selected= "selected";
echo $selected;
}
}
$html.= '<option '.$selected.' value="'.$row['id'].'">'.Purifier($cls_full_data).'</option>';
}
echo '<select name="class_id" id="class_id" class="form-control form-control-sm font-label">'.$html.'</select>';
echo '<br>';