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 8282487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:23:17+00:00 2026-06-08T10:23:17+00:00

Good day all, I have an html file as follows, which displays a Google

  • 0

Good day all,

I have an html file as follows, which displays a Google Map (initialised at window.onload function) and has a form to enter the name of a place to search. When the submit button is clicked then user input is supposed to be sent to a php file which get the coordinates to display on the map. However, in testing, all the php file is returning right now is the same userinput.

The problem I am having, is that this sequence of event happens:

I enter some text, and click submit.
The p element innerHTML is changed and the alert appears (as in onreadystatechange function)
However, when i close the alert, the p element loses its data.

I added the alert, because when i just used

document.getElementById("msg").innerHTML=xmlhttp.responseText;

the p element took on its new data briefly before disappearing.

On thing i noticed was that while the alert was on the screen, the address bar displayed “filename.html”. but when i closed it, and the p data disappeared, the address bar shows

filename.html?searchterm=user+input+stuff

Even when I click submit with the text input empty, I get “No Text Entered” appearing briefly, before the page “refreshes” then this text disappears, and the addressbar shows

filename.html?searchterm=

I appreciate any help I can get.

<html>
<head> 
<title>Map</title> 
<link rel="stylesheet" type="text/css" href="stylue.css" />   

<script type="text/javascript"      
src="http://maps.googleapis.com/maps/api/js? 
key=AIzaSyBksQ7NlV6eXk6w5w8222lolqdPHsN_8ls&sensor=false">    
</script> 

<script type="text/javascript">


var panorama;
var map;



function initialize() {

//create Google Map   
}

//other Google Maps functions   

function searchdb(userInput){

    var xmlhttp;    
    if (userInput==""){
        document.getElementById("msg").innerHTML="No Text Entered";
    }else{
        if (window.XMLHttpRequest){
    xmlhttp=new XMLHttpRequest();
        }
  else{
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }


  xmlhttp.onreadystatechange=function(){
  if (xmlhttp.readyState==4 && xmlhttp.status==200){
    document.getElementById("msg").innerHTML=xmlhttp.responseText;
    alert(xmlhttp.responseText);
  }
        }
        xmlhttp.open("GET","searchpageajax.php?searchterm="+userInput,true);
        xmlhttp.send();
   }

}

window.onload= function () { 
    initialize(); 
} 


</script>


</head>
<body >

<h1>Map</h1>

<p>Enter a room code or building name to search.</p>

<form name="inputform" >
<input type="text" name="searchterm" /> 
<input type="submit" value="Search" onclick="searchdb(searchterm.value)"/>
<input type="reset" value="Clear" />
<br/>
<p id ="msg"></p>
<br/>
</form>


<div id="container">
    <div id="map_canvas"></div>
    <div id="streetview_canvas"></div>
</div>

</body>
</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-06-08T10:23:19+00:00Added an answer on June 8, 2026 at 10:23 am

    The page is refreshed because your onsubmit function does not return false.

    See this post (there are probably others).

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

Sidebar

Related Questions

Good day to all. I have this structure <html> <iframe> <div id=idd>Some Content</div> </iframe>
Good day to all. I have a problem with the following code: textBox.addEventListener(KeyboardEvent.KEY_DOWN,handler); function
Good day to all. I have the following setup: A page with html, js,
Good day all, first of all, what am trying to do is have an
Good day to all, I have the following problem I have to convert the
Good day everyone. I have been having the same problem all day at work
Hi and Good day to all, Google App Script can be used in so
Good day all I have the following question: I would like to use Chart
Good day all; I have an UIImageView that I animate around a large UIView.
Good day I have a basic toolbar to which I added ImageIcon buttons. The

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.