Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8925965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:50:28+00:00 2026-06-15T07:50:28+00:00

Problem: When entering two form values (min/max price) does not update presented query results.

  • 0

Problem:

When entering two form values (min/max price) does not update presented query results. When first entered the results are correctly presented, but when form values are changed thereafter with new parameters, the html code is not updated to reflect these parameters.

HTML code:

<input type="text" size="5" placeholder="Min. price" id="price_min">
<input type="text" size="5" placeholder="Max. price" id="price_max">
<input type="button" onclick="getHotelInfo()" value="Get" />
<div id="hotel_info"></div>             

JavaScript code:

function getHotelInfo() {
    $.get('hotelservice.php?priceMin=' + $('input#price_min').val() + '&priceMax=' + $('input#price_max').val(), function(data) {
        var hotelInfo = JSON.parse(data);
        content = '<table style="font-size:10px;width:100%;"><tr><th>Name</th><th>Stars</th><th>Price</th></tr>';
        for (var hotel=0; hotel<5;hotel++) 
        {
            content += '<tr><td><a href="' + hotelInfo[hotel].externalLink + '">' + hotelInfo[hotel].name +'</a></td><td><center>' + hotelInfo[hotel].stars + '</center></td><td><center>' + hotelInfo[hotel].price + '</center></td></tr>';
        }
        content += '</table>';
        $('#hotel_info').replaceWith(content);
    });
}

PHP code:

$priceMin = $_GET['priceMin'];
$priceMax = $_GET['priceMax'];

$xml_source = file_get_contents('http://www.kayak.com/h/rss/hotelrss/SE/vaxjo?mc=EUR');
$xml = simplexml_load_string($xml_source);
$result = array();
foreach ($xml->channel->item as $item) {
    $kyk = $item->children('http://www.kayak.com/h/rss/hotelextension');
    $price = (int)$kyk->price;
    if ($price < $priceMax && $price > $priceMin) {
        $entry = new stdClass();
        $entry->name = (string)$item->title;
        $entry->externalLink = (string)$item->link;
        $entry->price = $price;
        $entry->stars = (int)$kyk->stars;
        $result[] = $entry;
    }
}
echo json_encode($result);

Desired output:
When form values are changed and getHotelInfo() is called, the new results should be reflected.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:50:29+00:00Added an answer on June 15, 2026 at 7:50 am

    I tested your script and the problem is that (from my brief testing) the PHP script sometimes return less than 5 results and then you still try to fetch 5 results (in the for-loop). This causes the script to access properties of an object that does not exists and this causes an error and the script fails. Therefor nothing gets updated.

    Anyway, I went a head and updated the script for you so the returned data is max 5 or the length of the returned data from the PHP-script. The new javascript function looks like this:

    function getHotelInfo() {
        $.get('test.php?priceMin=' + $('input#price_min').val() + '&priceMax=' + $('input#price_max').val(), function(data) {
            var hotelInfo = JSON.parse(data);
            var limit = hotelInfo.length > 5 ? 5 : hotelInfo.length;
    
            content = '<table style="font-size:10px;width:100%;"><tr><th>Name</th><th>Stars</th><th>Price</th></tr>';
            for (var hotel=0; hotel< limit;hotel++) 
            {
                content += '<tr><td><a href="' + hotelInfo[hotel].externalLink + '">' + hotelInfo[hotel].name +'</a></td><td><center>' + hotelInfo[hotel].stars + '</center></td><td><center>' + hotelInfo[hotel].price + '</center></td></tr>';
            }
            content += '</table>';
            $('#hotel_info').html(content);
        });
    }
    

    Hope this solves your problems!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem Overview: My application has an enrollment form. Users have a habit of entering
I have a form with two UITextFields and a button. The user enters values
I am having a problem with Scrapy, for some reason it is not entering
I have a problem animating border-top-left-radius style. I use this style by entering two
I'm having a problem with hover on images. When entering the site the hover-state
Problem: I have two array where one produce a category and the second produce
My problem is: Main form has 9 command buttons and continuous subform. Click on
I have seen this error before but got around it by entering values manually,
This is my first shot at brute-forcing the NP-complete knapsack problem . In this
I've got a somewhat unique problem due to our infrastructure. I have two offline

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.