Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

debug java script code i cant find the error its not letting me submit

<!DOCTYPE html> <html> <head> <style> h1 { color: purple; font-size: 30pt; font-weight: 900;

      }
  body {
            background: url("http://luxurycarsbest.com/wp-content/uploads/2014/10/luxury-car-dealerships.jpg");
            background-size: 1470px 800px;
            background-repeat: no-repeat;
            padding-top: 80px;
      }

</style> <script type="text/javascript"> function sendRequest(input,location) { xhttp=new XMLHttpRequest(); var URL1 = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20local.search%20where%20query%3D%22"; var URL2=escape(input); var URL3 ="%22%20and%20location%3D%22"; var URL4 = escape(location); var URL5 = "%22&diagnostics=true"; var URL=URL1+URL2+URL3+URL4+URL5; xhttp.open("GET",URL,true); xhttp.onreadystatechange = handleOutput; xhttp.send(null); xhttp.overrideMimeType('text/xml');

}

function handleOutput() { if (xHttp.readyState == 4) { if(xHttp.status == 200) { var xmlDoc = xmlHttp.responseXML; var resultNodes=xmlDoc.getElementsByTagName("Result"); var children; var resultTitle; var resultAddress; var resultCity; var resultState; var resultPhone; var resultDistance; var resultRating; var resultMapUrl; var tagTitle; var tagAddress; var tagCity; var tagState; var tagPhone; var tagDistance; var tagRating; var tagMapUrl;

for (var i=0; i < resultNodes.length; i++) { children = resultNodes[i].childNodes; resultTitle="Title: " + children[0].firstChild.nodeValue; tagTitle="returnedTitle" + i; document.getElementById(tagTitle).innerHTML=resultTitle; resultAddress="Address: " + children[1].firstChild.nodeValue; tagAddress="returnedAddress" + i; document.getElementById(tagAddress).innerHTML=resultAddress; resultCity="City: " + children[2].firstChild.nodeValue; tagCity="returnedCity" + i; document.getElementById(tagCity).innerHTML=resultCity; resultState="State: " + children[3].firstChild.nodeValue; tagState="returnedState" + i; document.getElementById(tagState).innerHTML=resultState; resultPhone="Phone: " + children[4].firstChild.nodeValue; tagPhone="returnedPhone" + i; document.getElementById(tagPhone).innerHTML=resultPhone; resultRating="Rating: " + children[7].firstChild.nodeValue; tagRating="returnedRating" + i; document.getElementById(tagRating).innerHTML=resultRating; resultDistance="Distance: " + children[8].firstChild.nodeValue + " Miles"; tagDistance="returnedDistance" + i; document.getElementById(tagDistance).innerHTML=resultDistance; resultMapUrl="MapUrl: " + children[11].firstChild.nodeValue + " direction to the car dealership"; tagMapUrl="returnedMapUrl" + i; document.getElementById(tagMapUrl).innerHTML=resultMapUrl; } } } }

    </script>
</head>
<body>
    <form name="form1" method="get" action="">
        <div align="center">dealership: 
            <INPUT TYPE="text" Name="typeof">
            </div>
            <br>
                <br>
                    <div align="center">Location: 
                        <INPUT TYPE="text" Name="locations">
                        </div>
                        <br>
                            <br>
                                <INPUT TYPE="button" VALUE="Submit" onClick="JavaScript:sendRequest(document.form1.typeof.value,document.form1.locations.value)">
                                </div>
                                <center>
                                    <div id = "returnedTitle"></div>
                                    <center>
                                        <center>
                                            <div id = "returnedAddress"></div>
                                            <center>
                                                <center>
                                                    <div id = "returnedCity"></div>
                                                    <center>
                                                        <center>
                                                            <div id = "returnedState"></div>
                                                            <center>
                                                                <center>
                                                                    <div id = "returnedPhone"></div>
                                                                    <center>
                                                                        <center>
                                                                            <div id = "returnedDistance"></div>
                                                                            <center>
                                                                                <center>
                                                                                    <div id = "returnedRating"></div>
                                                                                    <center>
                                                                                        <center>
                                                                                            <div id = "returnedMapUrl"></div>
                                                                                            <center>
                                                                                            </form>
                                                                                        </body>
                                                                                    </html>

3 Answers

For one, you didn't close your "style" tag. That's the first thing that jumps out at me.

can you breakdown the yql url please for javasript into 5 urls so i can use it

can you breakdown the yql url please for javasript into 5 urls so i can use it