我有这样的代码,我从后端执行:
$statement = $PDO->prepare($query);
$statement->execute($parameters);
if($statement->rowCount()>0)
{
$resultSet = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($resultSet as $key => $value)
{
$return .= "<option value='".$resultSet[$key]['bwid']."'>".$resultSet[$key]['bname']." - ".$resultSet[$key]['final_count']."</option>";
}
}
else
{
$return = "<option>$lbldisp_text_nosuppfound</option>";
}
echo json_encode($return);
如何添加标签&#34; 选择分支&#34; (我希望它作为第一选择)?
谢谢。
答案 0 :(得分:0)
只需将您的标签附加到$ return变量
即可$return .= '<label>Write text here</label>';
$return .= "<option value='".$resultSet[$key]['bwid']."'>".$resultSet[$key]['bname']." - ".$resultSet[$key]['final_count']."</option>";
echo $return;
答案 1 :(得分:0)
只需添加标签标签并在其中写下标签文字。
$return .= "<label>choose branch</label>";
$return .= "<option value='".$resultSet[$key]['bwid']."'>".$resultSet[$key]['bname']." - ".$resultSet[$key]['final_count']."</option>";
答案 2 :(得分:0)
Hello @chrisjai32 try this out
<div id="part">
<label>choose branch</label>
<input type="text" id="" placeholder="Branch Name" autocomplete="off">
<input type="hidden" name="branch_id" id="branch_id">
<div id="branch_options">
<option value="0">--choose branch--</option>
<?php foreach("$branches as $b") { ?>
<option value="<?php echo $b->branch_id; ?>">
<?php echo $c->branch_name; ?>
</option>
<?php } ?>
</div>
</div>
答案 3 :(得分:0)
首先,您必须在选项周围添加一个元素,以获得有效的html文档。
然后,您可以在选择
中添加禁用选项protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALLERY_INTENT && resultCode == RESULT_OK)
{
String sTypes = data.getStringExtra(sExamType);
StorageReference reference;
if(TextUtils.equals(sTypes,"timetable") && !TextUtils.isEmpty(sTypes) {
reference = mStorageRef.child(college).child(branch).child(year).child(section).child("timetable");
}else if(TextUtils.equals(sTypes,"timetable") && !TextUtils.isEmpty(sTypes)
{
reference = mStorageRef.child(college).child(branch).child(year).child(section).child("exam");
}else
{
Toast.makeText(getApplicationContext(),"error",Toast.LENGTH_SHORT).show():
}
progressDialog.setMessage("Image Uploading....");
progressDialog.show();
Uri uri = data.getData();
reference.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Toast.makeText(getApplicationContext(),"Photo Uploaded!!!",Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getApplicationContext(),"Unable to Upload!!!",Toast.LENGTH_SHORT).show();
progressDialog.dismiss();
}
});
}
}
答案 4 :(得分:0)
根据我的理解,您想要在第一个选项中添加标签“选择分支”,因此它在列表中显示为<label>
。要实现此目的,您需要在列表中添加一个新选项,但禁用它并将其设置为选中。
在开始使用foreach循环向$return
添加选项之前,请添加以下行:
$return .= "<option selected disabled>choose branch</option>";
答案 5 :(得分:0)
@ chrisjai32这是我上面回答的脚本
<script>
$(document).ready(function(){
$(document).on("click", "#check_branches", function(e){
branch_id = $("#branch_id").val();
$.ajax({
type: "GET",
url: "<?php echo url('/'); ?>/check_branch/"+brand_id,
success:function(result){
$("#result").html("available " + result);
}
});
return false;
});
});
</script>