Reputation: 57
I am able to retrieve the latlng of a particular place in google map and I wanted it to be shown in the textbox so that I can use php to insert it to mySQL database. But it seems like my method somehow wasn't correct. It does not display if I use textbox but it display when I use div. Below are the following codes:
Javascript
document.getElementById("test").innerHTML = "<br/><br/><br/>Location 1 coordinates are: "+location1+"";
HTML
<center><input type="text" id="test" value="" size="30"/></div></center>
Thanks.
Upvotes: 0
Views: 2182
Reputation: 57650
You can not set innerHTML property of an input Object. use Value property instead.
document.getElementById("test").value = "<br/><br/><br/>Location 1 coordinates are: "+location1+"";
Also using html tag is not recomended in input element. Its used for text. So use it like
document.getElementById("test").value = "Location 1 coordinates are: "+location1+"";
Upvotes: 1
Reputation: 359836
Use .value
, not .innerHTML
, to set the value of a text input element.
Upvotes: 3
Reputation:
Use the .value
property.
document.getElementById("test").value = "<br/><br/>...";
But of course this will give you HTML markup, not DOM elements as you may be expecting.
If you want line breaks, you need to use a <textarea>
instead of an <input>
.
document.getElementById("my_textarea").value = "\n\n\nLocation 1 coordinates are: " + location1;
Note that you don't need the closing + ""
.
Upvotes: 1