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

  • Home
  • SEARCH
  • 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 8478753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:50:00+00:00 2026-06-10T18:50:00+00:00

A have a price comparison website with a user input form in the sidebar.

  • 0

A have a price comparison website with a user input form in the sidebar. When a user starts using the form (ticking checkboxes, radio buttons etc.), I need to dynamically update the main content area (comparison table) of the page depending on what options the user is checking. Currently, I’m using AJAX to load the contents of a PHP file into a DIV in the content area. The PHP file just has a PHP query to pull content from a database and then output it. This isn’t a MySQL query, it’s a PHP call for a price comparison package I use, just using arguments like “+blue +widget min_price=10 max_price=200” etc. The MySQL query is then handled by the package.

When I hard code everything, it works fine, so that’s a good start. The problem is, I need to dynamically generate the query string depending on what the user is selecting on the form, then pass it to the PHP file during the AJAX call, to pull the right content into the DIV. The query string needs to update and the call needs to happen every time a user changes something on the form. So, for example, if a user ticks a box for the colour “blue”, I need to add “+blue” onto the string and resend the AJAX call. If they untick blue, I need to remove “+blue” and resend the AJAX call etc. etc.

I’m out of my depth at this point, so would appreciate any guidance on how to achieve something like this…

Currently, I have this:

The content div that gets updated is called “pbDiv”.

AJAX:

<script type="text/javascript">
function updateTable(str)
{
if (str=="")
  {
  document.getElementById("pbDiv").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("pbDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","http://MYSITE//pricebox.php?q="+str,true);
xmlhttp.send();
}
</script>

Form:

<form>
<select name="colour" onchange="updateTable(this.value)">
<option value="">Select a colour:</option>
<option value="blue">Blue</option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="yellow">Yellow</option>
</select>
</form>

The PHP file just takes the string, and works fine. The problem, as you might have guessed, is that this form only works for one thing (colour). Using this.value just passes the choice of that dropdown. I don’t know how I could use multiple form items and build a string.

  • 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-10T18:50:02+00:00Added an answer on June 10, 2026 at 6:50 pm

    for each form item give one unique id, then for each item call updateTable function but dont pass the value while calling the function for example::

    now modify your updateTable function like this

    function updateTable(){
    var str = 'color = '+ document.getElementById('colorField').value;
        str += 'something = '+ document.getElementById('somethingField').value;
    //now carry on your ajax stuff
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have got a price comparison website. You can click on a link of
I have generated inputs with price values. Example: <input type=text value=59,00/> Now I should
I have a form that saves the price into the database but whn a
I have a form that the user is going to interact with, by updating,
I currently use an external service for a price comparison unit I have on
I am crawling online stores for price comparison. Mot of the stores are using
Using some basic website scraping, I am trying to prepare a database for price
I am working on a price comparison program. I have three websites. In my
I am working on a small price/product comparison website, it's a niche website related
I have a 'price' variable that contains some integer number from a MySQL database.

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.