1
function calculateDisplay () {
    var province = document.forms["calculateForm"]["province"].value;
...
...
document.getElementById("secondHeader").innerHTML = "Canada | " + province + " | 2017 Tables";

return false;
}

how do I format to display the variable province as color: black (usually that secondHeader id is lightgrey)

Thank you!

1
  • Put it inside a <span> tag. Commented May 12, 2017 at 16:22

1 Answer 1

1

Please let me know if this is what you're looking for.

function calculateDisplay() {
  var province = document.forms["calculateForm"]["province"].value;
  document.getElementById("secondHeader").innerHTML = "Canada | <span class=\"province-color\">" + province + "</span> | 2017 Tables";
  return false;
}

calculateDisplay();
<style type="text/css">
  .province-color {
    color: #000;
  }
</style>
<span id="secondHeader" style="color:green;"></span>
<form id="calculateForm">
  <input type="text" name="province" value="Alberta" />
</form>
<button onClick="calculateDisplay();">Re-calc</button>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.