I want to be able to post all the information of the selected list link onto the page
This is the format of the json file i am using
- {
- "year": 2013,
- "title": "Rush",
- "info": {
- "directors": ["Ron Howard"],
- "release_date": "2013-09-02T00:00:00Z",
- "rating": 8.3,
- "genres": [
- "Action",
- "Biography",
- "Drama",
- "Sport"
- ],
- "image": "https://ia.media-imdb.com/images/M/MV5BMTQyMDE0MTY0OV5BMl5BanBnXkFtZTcwMjI2OTI0OQ@@._V1_SX400_.jpg",
- "plot": "A re-creation of the merciless 1970s rivalry between Formula One rivals James Hunt and Niki Lauda.",
- "rank": 2,
- "running_time_secs": 7380,
- "actors": [
- "Daniel Bruhl",
- "Chris Hemsworth",
- "Olivia Wilde"
- ]
- }
i want to post all the information of the selected link in the drop down list onto the html page. only certain data is shown on the drop-down list but i want all the information to be shown on the page once the user clicks on the specific link.
- <!DOCTYPE html>
- <html>
- <head>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <style>
- #result {
- position: absolute;
- width: 100%;
- max-width:870px;
- cursor: pointer;
- overflow-y: auto;
- max-height: 400px;
- box-sizing: border-box;
- z-index: 1001;
- }
- .link-class:hover{
- background-color:#f1f1f1;
- }
- </style>
- </head>
- <body>
- <br /><br />
- <div class="container" style="width:900px;">
- <h2 align="center">Search for a Movie</h2>
- <h3 align="center">Movie Data</h3>
- <br /><br />
- <div align="center">
- <input type="text" title="search" id="search" placeholder="Search Movie Details" class="form-control" />
- </div>
- <ul class="list-group" id="result"> </ul>
- <p>
- </p>
- <br />
- </div>
- <script>
- $(document).ready(function(){
- $.ajaxSetup({ cache: false });
- $('#search').keyup(function(){
- $('#result').html('');
- $('#state').val('');
- var searchField = $('#search').val();
- var expression = new RegExp(searchField, "i");
- $.getJSON('MovieData.html', function(data) {
- $.each(data, function(key, value){
- if (value.title.search(expression) != -1)
- {
- $('#result').append('<li class="list-group-item link-class"><img src="'+value.image+'" height="203" width="144" class="img-thumbnail" /> '+value.title+' | <span class="text-muted">'+value.info.genres+'</span></li>');
- }
- });
- });
- });
- $(document).ready(function(){
- $('#result').on('click', 'li', function() {
- var $this = $(this);
- var $alias = $this.data('alias');
- $('.active').removeClass('active');
- $this.toggleClass('active')
- myfuncation($this, $alias)
- })
- function myfuncation($this, $alias){
- console.log($this.text());
- console.log($alias);
- }
- });
- });
- </script>
- </body>
- </html>
- This is what the list looks like and i want to show all the details of the movie once it has been clicked.
- Any help will be greatly appreciated