Jump to content

clearing information


hamburgerlove413

Recommended Posts

Hello,

 i wasn't sure of a good way to title this post but, I have this app that for right now, you type in band name and it grabs that band's concerts from last.fm API (without using a submit button). This part works, but then when i type a new band/artist in to the input box, instead of replacing the previous band's concerts, it just adds to it. Does anyone know of a way to delete the previous information once a new band name is typed in?

 

the html:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Assignment 03 Mashup – Nicholas Barna</title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/script.js"></script>

<link href="css/styles.css" rel="stylesheet" type="text/css">

</head>

<body>

<div id="container" class="globalWidth">

    <form name="artistSearch" id="artistSearch" method="get">
    
        <label for="artistName">Artist or band name:<input type="text" name="artistName" id="artistName" /></label>
    
    
    </form>
    
    <span id="searchTitle">search for:</span><span id="searchItem"></span>
    
    <div id="artist">
    
    
    </div>

</div>

</body>
</html>

the Javascript:


$(document).ready(function () { 

	$("#artistName").on("keyup change", function() {
		
		artistName = this.value;
				
		$.get("http://ws.audioscrobbler.com/2.0/?method=artist.getevents&artist=" + artistName + "&api_key=69d935120d26cbcbaeed4fac6f59dfb6", function(xml) {
			
			
			$(xml).find("venue").each( function() {
					
				title = $(this).find("name").text();

				$("#artist").append(title);
			
			});
					


		});
		
	
  		$("#searchItem").text(this.value);
	});
	

});
Link to comment
https://forums.phpfreaks.com/topic/287871-clearing-information/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.