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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:45:35+00:00 2026-05-23T23:45:35+00:00

I have a form (will add form validation later) that allows the user to

  • 0

I have a form (will add form validation later) that allows the user to ‘Add a Property’ for a real estate site. Here’s my html/js:

<!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=utf-8" />
<title>Add New Property</title>

<script type="text/javascript">

function addProperty() {
    var name = document.getElementById('name').value;
    var address = document.getElementById('address').value;
    var lat = document.getElementById('lat').value;
    var lng = document.getElementById('lng').value;
    var type = document.getElementById('type').value;
    var rent = document.getElementById('rent').value;
    var bedrooms = document.getElementById('bedrooms').value;
    var owner_id = document.getElementById('owner_id').value;

    if (window.XMLHttpRequest) {
        //code for IE7+, Firefox, Chrome and Opera
        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('message').innerHTML = xmlhttp.responseText;
        }
    }

    var url = "add_property.php?name="+name+"&address="+address+"&lat="+lat+"&lng="+lng;
    url += "&type="+type+"&bedrooms="+bedrooms+"&owner_id="+owner_id;

    xmlhttp.open("GET", url, true);

    xmlhttp.send();

}

</script>


</head>

<body>
<form>

Property Name:
<input type="text" name="name" id="name" />
<br />
Address:
<input type="text" name="address" id="address" />
Lat: <input type="text" name="lat" id="lat" />
Lng: <input type="text" name="lng" id="lng" />
<br />
Type of property:
    <select name="type" id="type">
        <option value="house">House</option>
        <option value="apartment">Apartment</option>
    </select>
<br />
Number of Bedrooms:
<input type="text" name="bedrooms" id="bedrooms" />
<br />
Owner Id:
<input type="text" name="owner_id" id="owner_id" />
<br /><br />
<input type="button" value="Add Property" onclick="addProperty()" />

</form>
<div id="message"></div>
</body>
</html>

Here’s my php:

<?php require_once("includes/initialize.php"); ?>

<?php

$name = $_GET['name'];
$address = $_GET['address'];
$lat = $_GET['lat'];
$lng = $_GET['lng'];
$type = $_GET['type'];
$rent = $_GET['rent'];
$bedrooms = $_GET['bedrooms'];
$owner_id = $_GET['owner_id'];

//this text won't come back...
$message = $name.$address.$lat.$lng.$type.$rent.$bedrooms.$owner_id;


echo $message;

?>

I know it’s probably a minor syntax error, which is something I usually wouldn’t ask about on SO but I’ve spent 2+ hours on it and am overly frustrated. Thanks.

  • 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-23T23:45:36+00:00Added an answer on May 23, 2026 at 11:45 pm

    UPDATE: var rent = document.getElementById('rent').value; threw error because there was no element with id “rent”.

    OLD: You are not cancelling the default action of the submit button. Return false from addProperty method and then you should see the response.

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

Sidebar

Related Questions

I have a form a user can enter their name, then it will add
I have a Django form that will add an entry to a database with
I have a form that will multiple Panel controls stacked on top of each
The functionality I'm looking for: I have a form that will search my 'Proposal'
(Using MySQL and PHP) I have a search form that will allow my users
I have a form with a hidden Came from Adwords field that will be
I have a form which have many check boxes in it. User will check
I have a delete form wherein the user will enter the pnum to be
I have a form generator that uses (perl compatible) regexes for ther backend validation.
I have a form that works in 'sections' that I will refer to as

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.