Formatting text generated by js script

Jorge Batres
Jorge Batres used Ask the Experts™
on
Hi, I have a js script that I use to display a message and I need help editing the script to highlight parts of the rendered text.

The script generates a message like this:

This reservation is for a One Bedroom Condo for 3 nights arriving on Monday, September 24, 2019, and departing on Thursday, September 27, 2019, with the choice of No Tickets Included.

and I would like to highlight some parts of the text like this:

This reservation is for a One Bedroom Condo for 3 nights arriving on Monday, September 24, 2019, and departing on Thursday, September 27, 2019, with the choice of No Tickets Included.

On the script, I believe the section that displays the message is this:
 else {
      var descText = "";
      var roomTypeText = $("#roomTypeSel option:selected").text();
      if (roomTypeText) descText += "This reservation is for a "+ roomTypeText+" for  ";
      descText+=days +" night"+(days==1?"":"s")+" arriving on "+arrivalDate+" and departing on "+departureDate
      var ticketChoice = $("#Tickets option:selected").text();
      if (ticketChoice && ticketChoice!= "No Tickets") descText += " with the choice of " +ticketChoice;
      $("#description").html(descText);
      getPrice(dateString,days,roomType);

Open in new window


Please help me edit the attached file to get the desired result.

Note: By highlight, I mean bold text.

Thanks,

Jorge B
calendarmain.js
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Analyst Assistant
Commented:
I'm sure there are better ways but try this.
 else {
      var descText = "";

      var roomTypeText = $("#roomTypeSel option:selected").text();

      if (roomTypeText) descText += "This reservation is for a <strong>"+ roomTypeText+"</strong> for <strong>";

      descText+=days +" night"+(days==1?"":"s")+"</strong> arriving on <strong>"+arrivalDate+"</strong> and departing on <strong>"+departureDate+"</strong>"

      var ticketChoice = $("#Tickets option:selected").text();

      if (ticketChoice && ticketChoice!= "No Tickets") descText += " with the choice of <strong>" +ticketChoice +"</strong>";

      $("#description").html(descText);

      getPrice(dateString,days,roomType);

Open in new window

Author

Commented:
Thank you so much. Your solution worked well in all browsers.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial