我需要在表单属性中添加这个称呼。
<script type="text/javascript">
function edit()
{
obj->display_edit();
}
</script>
怎么做?
答案 0 :(得分:1)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<form>
<label>Name with Initials</label>
<div class="input-group">
<span class="input-group-addon">
<select name="sal">
<option selected="selected" value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Miss">Miss</option>
</select>
</span>
<input type="text" name="Name" class="form-control" placeholder="Full Name" oninput="FullName.value = sal.value +' '+ Name.value">
</div><!-- /input-group -->
<input type="hidden" name="FullName" />
</form>
</div>
&#13;
答案 1 :(得分:0)
您需要在form-control
代码中添加课程select
。
<select class="form-control" id="">
这是完整的HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<form>
<div class="form-group" style="border:1px solid red;padding:10px;">
<label>Name with Initials</label>
<select class="form-control" id="">
<option selected="selected" value="Operation">Mr.</option>
<option value="NPA">Mrs.</option>
<option value="BTS-Kurunegala">Miss.</option>
</select>
</div>
</form>
</div>
答案 2 :(得分:0)
我已为该示例添加了<form>
和提交按钮。基本上,您需要将选项的值更改为内部文本,如下所示:
<option value="Mr." selected>Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Miss.">Miss.</option>
并且您需要使用一些JavaScript / jQuery获取<select>
的值并将其放入变量中,并在更改select时更新它。然后,在提交表单时,您需要获取输入中的文本并在输入的文本之前放置变量(和空格)。
title = $('#name_with_initials').val();
function titleChange() {
title = $('#name_with_initials').val();
}
function formSubmit() {
$('.form-control').val(title + ' ' + $('.form-control').val());
alert($('.form-control').val());
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="form-group">
<form onsubmit="formSubmit()">
<label>Name with Initials</label>
<select name="name_with_initials" id="name_with_initials" onchange="titleChange()">
<option value="Mr." selected>Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Miss.">Miss.</option>
</select>
<input type="text" name="name_with_initials" class="form-control" value="">
<input type="submit">
</form>
</div>
&#13;