Come posso fare precompilare un campo di input HTML con una variabile? In questo caso, la variabile modale del corpo. Ho letto sull'uso di document.write ma come potremmo usarlo con una variabile?Prefilla un valore HTML con una variabile?
Stiamo utilizzando Mandrill & Calendario completo.
Molte, molte grazie!
CODICE:
{
title: 'Event',
start: '2016-03-26T11:00:00',
end: '2016-03-26T12:00:00',
},
],
eventClick: function(event) {
console.log(event)
// alert(event.start.format('MMMM Do YYYY'))
var start = event.start.format('MMMM Do YYYY'),
end = event.end.format('MMMM Do YYYY'),
html = '<p>Starts: ' + start + '<p>';
html += '<p>Ends: ' + end + '<p>';
var modal = $("#modal");
modal.find(".modal-title").html(event.title);
modal.find('.modal-body').html(html)
modal.modal();
}
});
});
});//]]>
</script>
<script type="text/javascript">
$(document).ready(function() {
// Generate a simple captcha
function randomNumber(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
function generateCaptcha() {
$('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));
}
generateCaptcha();
$('#contactForm')
.formValidation({
})
.on('success.form.fv', function(e) {
// Prevent default form submission
e.preventDefault();
// Change these values to match with your application
var MANDRILL_API_KEY = 'YOUR-MANDRILL-API-KEY',
EMAIL_SUBJECT = 'Find Volunteerships - Sign Up Confirmation ',
var $form = $(e.target),
// Generate a message based on submitted form data
body = [
'<strong>Name:</strong> ' + $form.find('[name="firstName"]').val() + ' ' + $form.find('[name="lastName"]').val(),
'<strong>School</strong> ' + ($form.find('[name="school"]').val() || 'n/a'),
'',
'<strong>Message:</strong> ',
$form.find('[name="school"]').val()
].join('<br/>');
// Send the message
$.ajax({
type: 'POST',
url: 'http://mandrillapp.com/api/1.0/messages/send.json',
contentType: 'text/plain',
dataType: 'json',
data: {
key: MANDRILL_API_KEY,
message: {
from_name: $form.find('[name="fullName"]').val(),
from_email: $form.find('[name="email"]').val(),
to: [
{
email: $form.find('[name="email"]').val(),
name: $form.find('[name="fullName"]').val(),
'type': 'to'
}
],
auto_text: true,
subject: EMAIL_SUBJECT,
html: body
}
}
}).done(function(response) {
// Clear the form
$form.formValidation('resetForm', true);
// Regenerate the captcha
.on('err.form.fv', function(e) {
// Regenerate the captcha
generateCaptcha();
});
// Show the message
response.status === 'error'
? $('#alertContainer')
.removeClass('alert-success')
.addClass('alert-warning')
.html('Sorry, cannot register the sign up')
.show()
: $('#alertContainer')
.removeClass('alert-warning')
.addClass('alert-success')
.html('Your sign up has been successfully registered')
.show();
}).fail(function(jqXHR, textStatus, errorThrown) {
$('#alertContainer')
.removeClass('alert-success')
.addClass('alert-warning')
.html('Sorry, cannot register the sign up')
.show();
});
Potresti metti questo in un violino? Ho problemi a capire il tuo codice –
Il codice inizia: '{ title: 'Event', start: '2016-03-26T11: 00: 00', fine: '2016-03-26T12: 00: 00', }, 'questo è un oggetto letterale? Se è così, ha bisogno di un nome: es. 'var obj =' – zer00ne
C'è un ']' dopo, quindi questa è una matrice di oggetti? Si prega di assicurarsi di tagliare e incollare con cura. – zer00ne