Javascript n在选择其各自的选项后。我已经在编辑后的描述中添加了代码,您可以检查。是的,这就是您所要求的。确保你的问题尽可能准确。如果你需要跟进你的问题,那么我建议你打开一个新的问题,并将这个答案标记为未来读者可以接受。 <select name="s
Javascript n在选择其各自的选项后。我已经在编辑后的描述中添加了代码,您可以检查。是的,这就是您所要求的。确保你的问题尽可能准确。如果你需要跟进你的问题,那么我建议你打开一个新的问题,并将这个答案标记为未来读者可以接受。 <select name="s,javascript,jquery,node.js,mongoose,handlebars.js,Javascript,Jquery,Node.js,Mongoose,Handlebars.js,n在选择其各自的选项后。我已经在编辑后的描述中添加了代码,您可以检查。是的,这就是您所要求的。确保你的问题尽可能准确。如果你需要跟进你的问题,那么我建议你打开一个新的问题,并将这个答案标记为未来读者可以接受。 <select name="sources" id="sources" class="custom-select sources" placeholder="Requirement Completed"&
n在选择其各自的选项后。我已经在编辑后的描述中添加了代码,您可以检查。是的,这就是您所要求的。确保你的问题尽可能准确。如果你需要跟进你的问题,那么我建议你打开一个新的问题,并将这个答案标记为未来读者可以接受。
<select name="sources" id="sources" class="custom-select sources" placeholder="Requirement Completed">
<option value="profile" selected="selected">In Progress</option>
<option value="word">Done</option>
<option value="hashtag">Rejected</option>
</select>
<script>
$(".custom-select").each(function() {
var classes = $(this).attr("class"),
id = $(this).attr("id"),
name = $(this).attr("name");
var template = '<div class="' + classes + '">';
template += '<span class="custom-select-trigger">' + $(this).attr("placeholder") + '</span>';
template += '<div class="custom-options">';
$(this).find("option").each(function() {
template += '<span class="custom-option ' + $(this).attr("class") + '" data-value="' + $(this).attr("value") + '">' + $(this).html() + '</span>';
});
template += '</div></div>';
$(this).wrap('<div class="custom-select-wrapper"></div>');
$(this).hide();
$(this).after(template);
});
$(".custom-option:first-of-type").hover(function() {
$(this).parents(".custom-options").addClass("option-hover");
}, function() {
$(this).parents(".custom-options").removeClass("option-hover");
});
$(".custom-select-trigger").on("click", function() {
$('html').one('click',function() {
$(".custom-select").removeClass("opened");
});
$(this).parents(".custom-select").toggleClass("opened");
event.stopPropagation();
});
$(".custom-option").on("click", function() {
$(this).parents(".custom-select-wrapper").find("select").val($(this).data("value"));
$(this).parents(".custom-options").find(".custom-option").removeClass("selection");
$(this).addClass("selection");
$(this).parents(".custom-select").removeClass("opened");
$(this).parents(".custom-select").find(".custom-select-trigger").text($(this).text());
});
$("#sources").val('2');
</script>
<table class="table table-hover">
<tbody id="append_status">
<tr>
<th>Topic (View)</th>
<th>Status</th>
<th>Deadline</th>
<th>Upload</th>
<th>Completion Date</th>
</tr>
{{#each user.Addtasks}}
<tr>
<td><a href="profileWriter/view/{{this._id}}">{{this.topic}}</a></td>
<td>
<div class="center">
<select name="sources" id="sources" class="custom-select sources" placeholder="Requirement Completed">
<option value="0" selected="selected">In Progress</option>
<option value="1">Done</option>
<option value="2">Rejected</option>
</select>
</div>
</td>
<td><span id="deadline"> {{this.deadline}}</span></td>
<td>
</td>
<td></td>
</tr>
{{/each}}
</tbody>
</table>
// Route that receives data.
app.post('/update-sources', (req, res) => {
// Store selected source in DB.
res.send('Data received')
});
// Route to navigate to, if you don't have that already.
app.get('/sources', (req, res) => {
// Retrieve selected source from DB and send it to the template.
res.render('sources', { selectedValue: value });
});
Handlebars.registerHelper('isselected', function (selectedValue, value) {
return selectedValue === value;
});
<select name="sources" id="sources" class="custom-select sources" placeholder="Requirement Completed">
<option value="profile" {{#if (isselected selectedValue "profile") }} selected {{/if}}>In Progress</option>
<option value="word" {{#if (isselected selectedValue "word") }} selected {{/if}}>Done</option>
<option value="hashtag" {{#if (isselected selectedValue "hashtag") }} selected {{/if}}>Rejected</option>
</select>
$('#sources').on('change', function(event) {
var $this = $(this);
var value = $this.val();
$ajax({
url: '/update-sources',
method: 'POST',
dataType: 'text',
data: {
selectedValue: value
}
}).done(function(response) {
console.log(response)
});
});