Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6865957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:07:08+00:00 2026-05-27T03:07:08+00:00

Following is the javascript code var text; var name; window.onload = init; function init()

  • 0

Following is the javascript code

var text;
var name;
window.onload = init;
function init() {
    var button = document.getElementById("submitButton");
    text = document.getElementById("nameTextInput");
    button.onclick = handleButtonClick;
}
function handleButtonClick() {
    if (text.value == "") {
        alert("oops !! Enter Name");
    }
    else {
        var content = document.getElementById("content");
        content.removeChild(h4);
        content.removeChild(img);
        content.removeChild(form);
        name = document.getElementById("name");
        name.innerHTML = text.value + ", I am tracking you at ";
        getMyLocation();
    }
}

When I click the button, the elements are removed but name div doesn’t show anything. It works on IE8 but in chrome, safari and opera it falters.

Following is the HTML :-

<body>
<div class="topMiddle">Locate ME ;-)
</div>
<div id="content" class="content">
    <h4 id="h4">Your Name</h4>
    <img id ="img" src="rows-hand-.png" alt="arrow image" height="70" width="70" />
    <form id="form">
        <input type="text" id="nameTextInput" size="40" placeholder="Enter your name dear" class="inputTextClass">
        <input type="button" id="submitButton" value="Submit" class="inputButtonClass">
    </form>
    <div id="name" class="name">
    </div>
    <div id="user" class="user">
        <div id="map_canvas"></div>
    </div>
    <div id="me" class="me">
    </div>
</div>

Following is the CSS :-

.content
{
    text-align:center;
    margin-top:10px;
}

h4 
{
    color: #E9E9E9;
}

.inputTextClass 
{
    width:150px;
}

.inputButtonClass
{
    margin-top:20px;
    width:80px;
}

.name
{
    color:#000;
    font-size:16px;
}

EDIT

Here is the online link :- http://rdinvent.com/locateMe.html

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:07:09+00:00Added an answer on May 27, 2026 at 3:07 am

    EDIT:

    It’s just this name which messes everything up:

    name = document.getElementById("name");
    

    Replace this line and the following with:

    document.getElementById("name").innerHTML = text.value + ", I am tracking you at ";
    

    And of course, remove the var name; at the beginning.

    name is a global property (window.name) and should not be used in the global scope otherwise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have the following JavaScript code: <script type=text/javascript> function clearRadioButtons() { document.getElementById(radiobutton1).checked=; //etc
I have the following code: <script type=text/javascript> $(function() { //div1 toggle function runEffect(){ var
I have the following Javascript code: function checkIfValid(){ var form = document.createuserform; if(form.fName.value ==
I wrote the following html file <code> <html> <head> <script text =text/javascript> function createCookie(name,value,days)
I'm using the following JavaScript code: <script language=JavaScript1.2 type=text/javascript> function CreateBookmarkLink(title, url) { if
I have the following basic function: <script type=text/javascript> function Form_Data(theForm) { var t=1; while
What is the main purpose of the following JavaScript code? <script> var QunarUtil=new function(){var
I am using the following JavaScript code: var a = [23, 34, 45, 33];
I have the following JavaScript code: oCoord = {x: null, y: null}; var aStack
I have the following JavaScript code to pop up a window in Internet Explorer.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.