1

I have some JavaScript I'm trying to edit. Basically the JavaScript is creating a button to click on if the color is red, which works, but I need to add the date to the actual href value.

if (color == "#DC3545") {
  var date = $("#selected_date").val();

  $("div.toolbar")
    .html('<a class="btn btn-primary" href="edit.php?Date=+date" >Edit Day</a>');
}
2
  • 1
    Look at the colorization in the question. It is using a literal string. Commented Sep 2, 2020 at 16:34
  • Yes, code highlighting can provide valuable clues. If your variable appears the same color as your string something's not right. Commented Sep 2, 2020 at 16:35

1 Answer 1

1

You just need to fix up your string concatenation:

$("div.toolbar")
  .html('<a class="btn btn-primary" href="edit.php?Date=' + date + '" >Edit Day</a>');
  // ---------------------------------------------------^----------^
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.