我正在开发一个JS程序,我有表单操作。如何在调用的URL中传递名为event.title的JS变量。目前,网址为/register
。我希望将其设为/register/some_name
。谢谢。
代码:
eventRender: function(event, element, view){
element = $(element);
if(event.holiday){
var date = moment(event.date).format("YYYY-MM-DD");
$(view.el[0]).find(".fc-day[data-date="+date+"]").html("<span>" + event.title + "</span>").addClass("holiday");
return false;
} else {
element.find('.fc-time').hide();
element.css("min-height", "30px").css("border-width", "0px").css("margin-bottom", "2px");
var text;
var operator;
element.addClass("course"+ event.id).addClass("event"+ event.id);
if(event.quantity == 1){
operator = " Termin";
} else if (event.quantity > 1){
operator = " Termine";
}
if(event.backgroundColor == "#fa3e54"){
text ='<form method="POST" action="/register/${event.title}"> <div class="coursename">'+event.title +'</div>' +
'<div class="course-date">Kurs nicht mehr buchbar</div></form>';
} else {
var register = '<div class="anmelden"><input type="hidden" name="token" value="'+event.id + ',' + event.date + ',' + event.time + ',' + event.quantity + '' + operator+'"><input type="submit" class="btn-u pull-right" value="Anmelden"></div></form>';
text ='<form method="POST" action="/register/${event.title}"> <div class="coursename">'+event.title +'</div>' +
'<div class="course-date">Termine: '+ event.date + '</div>' +
'<div class="course-time">Uhrzeit: '+ event.time + '</div>' +
'<div class="coursequantity">Kursdauer: ' + event.quantity + ' ' + operator + '</div>' + register;
element.find(".fc-content").append('<form method="POST" action="/register/${event.title}">'+register+'</form>');
}
}
答案 0 :(得分:1)
我认为只有来自action="..."
的{{1}}中的字符串连接错误
更改
<form>
为:
text ='<form method="POST" action="/register/${event.title}"> <div class="coursename">'+event.title +'</div>' +
所以
text ='<form method="POST" action="/register/'+event.title +'"> <div class="coursename">'+event.title +'</div>' +