Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.