Pre-populate HTML variable value?

How can I make the value of an HTML input field populated by a variable? In this case, the modal body variable. I read about using document.write, but how can we use this with a variable?

We use Mandrill and a complete calendar.
Thank you so much!

CODE:

{ 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(); }); 
+5
source share
1 answer

Not sure what you mean, maybe something like this?

 modal.find('.' + modal-body) 

But the can not variable has a name with a "-" sign in it.

" modal-body " is equal to " modal - body ", so it will be minus one from the other.

-1
source

Source: https://habr.com/ru/post/1244776/


All Articles