我尝试根据下拉列表中的选定值添加输入字段。
我想在//Get the recipient a user wants to send message
if(isset($_POST['recipname']) && !empty($_POST['recipname'])){
$recipname = mysqli_real_escape_string($dbc_conn,trim($_POST['recipname']));
$recipname = preg_replace('/\s+/', ' ',$recipname);
$sql = "
SELECT id, username,firstname ,
lastname , avatar ,
school
FROM $table_name
WHERE CONCAT('%', firstname,' ',lastname,'%') LIKE '%$recipname%' OR
CONCAT('%', lastname,' ',firstname,'%') LIKE '%$recipname%'
LIMIT 6
";
//Query database
}
上附加输入字段。我真的尝试了很多,但我找不到错误。也许这个社区中的某个人已经看到了它......
<div>
&#13;
$(document).ready(function () {
//Initialize tooltips
$('.nav-tabs > li a[title]').tooltip();
//Wizard
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
var $target = $(e.target);
if ($target.parent().hasClass('disabled')) {
return false;
}
});
$(".next-step").click(function (e) {
var $active = $('.wizard .nav-tabs li.active');
$active.next().removeClass('disabled');
nextTab($active);
});
$(".prev-step").click(function (e) {
var $active = $('.wizard .nav-tabs li.active');
prevTab($active);
});
// $(document).on('ready', function() {
// $("#input-4").fileinput({showCaption: false});
//});
});
function nextTab(elem) {
$(elem).next().find('a[data-toggle="tab"]').click();
}
function prevTab(elem) {
$(elem).prev().find('a[data-toggle="tab"]').click();
}
//according menu
$(document).ready(function()
{
//Add Inactive Class To All Accordion Headers
$('.accordion-header').toggleClass('inactive-header');
//Set The Accordion Content Width
var contentwidth = $('.accordion-header').width();
$('.accordion-content').css({});
//Open The First Accordion Section When Page Loads
$('.accordion-header').first().toggleClass('active-header').toggleClass('inactive-header');
$('.accordion-content').first().slideDown().toggleClass('open-content');
// The Accordion Effect
$('.accordion-header').click(function () {
if($(this).is('.inactive-header')) {
$('.active-header').toggleClass('active-header').toggleClass('inactive-header').next().slideToggle().toggleClass('open-content');
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
}
else {
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
}
});
return false;
});
&#13;
答案 0 :(得分:0)
没有标识为std::string
的元素,但有一个test1
。
你的附加语句也会提前关闭,所以你有一系列以逗号分隔的语句。
所以
test
$("#test1").append($("<label/>").text(i + ". Division Name"))
//move this bracket ^
...
}), $("<br/>"), $("<br/>");
//and put it here ^
$("#test").append($("<label/>").text(i + ". Division Name"), $("<input/>", {
class: 'form-control',
type: 'text',
name: 'name_' + i
}), $("<br/>"), $("<input/>", {
type: 'text',
value: sel_value,
name: 'NumbDiv_' + i
}), $("<br/>"), $("<br/>"));
$(document).ready(function () {
$('select#selectDiv').change(function () {
var sel_value = $(this).val();
if (sel_value == 0) {
$("#test").empty(); // Resetting Form
}
else {
$("#test").empty(); //Resetting Form
create(sel_value);
}
});
function create(sel_value) {
for (var i = 1; i <= sel_value; i++) {
$("#test").append($("<label/>").text(i + ". Division Name"), $("<input/>", {
class: 'form-control',
type: 'text',
name: 'name_' + i
}), $("<br/>"), $("<input/>", {
type: 'text',
value: sel_value,
name: 'NumbDiv_' + i
}), $("<br/>"), $("<br/>"));
}
}
});
答案 1 :(得分:0)
我发现了我的错误......我必须在选择选项之前插入ID var sel_value = $(&#39; option:selected&#39;)。val();
更正:var sel_value = $(&#39; #selectDiv选项:已选择&#39;)。val();