Jump to content

Write the value of a variable


samuvk
 Share

Recommended Posts

I have values stored in a variable in Javascript in this way:
var VariableCity = "Birmingham"
var VariableCapital = "Montgomery"
Now I would like to write the value stored in the variable in a determinated place in the HTML document as below.
How can I accomplish that?
I tried: document.write(VariableCity) but:
1. I got this error: "Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened."
2. That way I'm not indicating where to write it
THANK YOU SO MUCH!!!!!
  <body>  <div style="width:100%;border:0px solid #ededed;">   <div style="float:left;width:5%;">     <select id="SystemSelector" onChange="sendAndDraw(this.value)">      <option value="Al">Alabama</option>      <option value="Tx">Texas</option>     </select>   </div>   <div style="float:left;width:95%;">      <button onclick="loadEditor(SystemSelector.value)">Change type of Graph</button>            City: VariableCity      <div id="Piechart_div" style="width: 100%;"></div>   </div>  </div>  <div style="width:100%;border:0px solid #ededed;">      <div id="chartGauge_div" align='center' style="width:100%"></div>      Capital: VariableCapital  </div>  </body>

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...