Search the Community
Showing results for tags 'document.getElementById'.
-
Hello & Thanks , var player1Score = 10; var player2Score = 20; document.getElementById('keepScore').innerHTML = ' player2Score = ' + player2Score; I want to be able to display several items on one line with the above code or preferably something that works . Pls , how can I do this . Thanks
-
Hey, so I have a code where you click a button, it tells you to translate a word, then tells you if you are correct or incorrect. I am adding something so that when you get a word correct, it goes on the left side, when you get a word wrong, it goes on the left side. My code works, aside from one thing. When you get a word right, it lists it on the left side, but the next word replaces the previous word. Here is one of my functions: function spanishLocation(){ var num = Math.floor(Math.random() * locations.length); var locations_obj = locations[num]; var answer = prompt("Translate: " + locations_obj.spanish).toLowerCase(); if (answer == locations_obj.english){ document.getElementById("icorrect").innerHTML = "Correct"; document.getElementById("AddCorrect").innerHTML = locations_obj.spanish + ": " + locations_obj.english; document.getElementById("CorrectAnswer").innerHTML = ""; } else{ document.getElementById("icorrect").innerHTML = "Incorrect"; document.getElementById("CorrectAnswer").innerHTML = locations_obj.english; } } How do I change the document.getElementById("AddCorrect").innerHTML = locations_obj.spanish + ": " + locations_obj.english; so that it adds the word and its translation to a div, rather than replacing it? Does that make sense?
- 6 replies
-
- javascript
- add
-
(and 3 more)
Tagged with:
-
Greenhorned Newbie here. Thanks for your patience. In a mobile environment I discovered my "button" image disappears. This happens right after the image is clicked and the new page is loading. Is this event bubbling? How would I account for it? <a style="text-align: center; border-style: none;" href="http://" style="color: #000000" onmouseover="document.getElementById('pic1').src='b.png'; this.style.color='#0ebfe9'" onmouseout="document.getElementById('pic1').src='a.png'; this.style.color='#000000'"><img src="a.png" id="pic1"><br>Click-here</a> I chose using the above over css and a:hover becuase of the brevity of code. It also seemed to be overall easier for me to line up images with their corresponding linking text. Thanks for any suggestions, David
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head> <body><html><head><script>function showUser(str){if (str=="") { document.getElementById("txtHint").value=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","getuser.php?q="+str,true);xmlhttp.send();}</script></head><body> <form><select name="users" onchange="showUser(this.value)"><option value="">Select a person:</option><option value="1">1</option><option value="2">2</option></select><input name="buyername" type="text" id="txtHint" /> """" I WANT TO DISPLAY RESULT IN THIS FIELD"""" </form><br><div id="txtHint"><b>Person info will be listed here.</b></div> RESULT IS DISPLAYING HERE </body></html></body></html> QUESTION:I WANT TO DISPLAY RESULT IN MY INPUT FIELD<input name="buyername" type="text" id="txtHint" />AS YOU KNOW RESULT COMES FROMdocument.getElementById("txtHint").innerHTML=xmlhttp.responseText;
-
Hello internet. I am having an issue with the following code working. CODE: <script type="text/javascript">window.onload = function() {for (var i = 0; i < Tload.length; i++) {document.getElementById(Tload.id).value = Tload.value; }</script> The error code I am getting is: 'docement.getElementById(…)' is null or not an object