I've got an array of objects, that provides the user a list of suggestions as they start to type. What I would like to happen is that when the user selects which suggestion they want, and click the submit button, then a price that is connected to that suggestion is displayed in a <div> under the search bar. I've been unsuccessful up to this point.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Device Recycling</title>
<link rel="stylesheet" href="/device_recycle.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
var projects = [
{
Device: "iPhone",
Price1: "$299",
Price2: "$199"
},
{
Device: "iPhone 2",
Price1: "$199",
Price2: "$99"
}
];
$( "#device" ).autocomplete({
minLength: 0,
source: projects,
focus: function( event, ui ) {
$( "#device" ).val( ui.item.label );
return false;
},
select: function( event, ui ) {
$( "#device" ).val( ui.item.value );
$( "#price1" ).val( ui.item.price1 );
$( "#price2" ).html( ui.item.price2 );
return false;
}
})
$("#submit").click(function(){
$( "#Price" ).append( item.Price1 );
});
</head>
<body>
<h1 id="font1">Quick Device Qoute</h1>
<div class="FormContainer">
<input id="device"/>
<input id ="submit" type="image" src="http://icons.iconarchive.com/icons/elegantthemes/beautiful-flat-one-color/128/magnifying-glass-icon.png" alt="Submit button">
<div id="ATT_Button" class="hidden">
<input id ="ATT" type="image" src="http://classlawyer.lawyer/wp-content/uploads/2015/12/ATT-Logo-Image-Labeled-for-Reuse.png" alt="Submit button">
</div>
<div id="VZW_Button" class="hidden">
<input id ="VZW" type="image" src="http://educationinactionri.org/Portals/0/Uploads/Images/Verizon_small.jpg" alt="Submit button">
</div>
<div id="Price"></div>
</div>
</body>
</html>
Ultimately what I would like to end up doing is when the user hits submit, it displays Price1 in the <div> below, but then have another button that they can click to then see Price2. At this point though, I'll settle for just figuring out how to get Price1 in a <div> on clicking of the submit button.