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 4052442
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:19:14+00:00 2026-05-20T14:19:14+00:00

Hey, I’m having some trouble with this problem, and I don’t even know where

  • 0

Hey, I’m having some trouble with this problem, and I don’t even know where to start.
I’m using foxycart for an ecommerce website I’m building for my girlfriend, so sending values to the “cart” is limited to the input names foxycart is looking for.
IE; name, price, product_sku.

I have a tiny CMS backend that allows you to add different sizes, sku’s for those sizes and a different price for that size.

So, being that I’m using foxycart, I need hidden inputs to send the values to the cart.

<input type="hidden" name="name" value="Test" />
<input type="hidden" id="price" name="price" value="19.99" />
<input type="hidden" id="product_sku" name="product_sku" value="sku3445" />
<input type="hidden" id="product_id" name="product_id" value="123" />

This works good. sends the name, price and sku to the cart.

I’ve made a drop down box that lists the different sizes/prices related to that product. I’ve set it up so that selecting a different size changes the price:

<select id="single" name="options" />
<option name="option_price" value="19.99">Default - $19.99</option>
<option name="option_price" value="18.99">Test Size: 18.99</option>
</select>

function displayVals() {
var singleValues = $("#single").val();
("#item_price").html(singleValues);
$("#price").val(singleValues);
}
$("select").change(displayVals);
displayVals();

This works too, send the price selected to a div and the hidden price input(so you can see the new purchase price) and to the cart(so the cart is showing the price of the product you want to purchase)

And now for the question:
How do I set this up so that selecting a different size/price will change the hidden inputs so that the product_sku, and size name are updated along with the price?

I’m thinking I have to use some Jquery.ajax() call, but have no idea…

Would this work?:

Jquery:

$(document).ready(function(){
    $("form#get_stuff").change(function() {
    var product_id= $('#product_id').attr('value');

        $.ajax({
            type: "POST",
            url: get_stuff.php,
            data: "product_id="+product_id,
            success: function(data){
$('#product_inputs').html(data);    
            }
        });
    return false;
    });
});

the ‘data’ being:

from the php page?

This is my first foray into Jquery ajax, so I really have no idea.

Edit:

Sorry, I just read this over and it’s kind of confusing….
Here is the workflow I’m trying to accomplish:

Page loads:
using php, echo product name, price, sku. (This is the default)

Drop-box change:
using jquery, dynamically change the hidden inputs with new information based off the product_id, and the size selected from the drop-box (Update 4 hidden inputs based off the value from one value from a select menu)

  • 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-05-20T14:19:15+00:00Added an answer on May 20, 2026 at 2:19 pm

    Instead of using AJAX when the select box changes, you can also load the SKU and product ID when the page loads and add them as data on the option tags. One way to do this is to add them as classes like so:

    <select id="single" name="options">
        <option name="option_price" class="sku3445 id123" value="19.99">Default - $19.99</option>
        <option name="option_price" class="sku3554 id321" value="18.99">Test Size: 18.99</option>
    </select>
    

    Then using a little RegEx you can extract these values from the selected option in your change() function and update the hidden inputs accordingly:

    function displayVals() {
        var $single = $('#single'),
            singleValues = $single.val(),
            singleClasses = $single.find('option:selected').attr('class'),
            singleSKU = singleClasses.match(/\bsku\d+\b/)[0],
            singleID = singleClasses.match(/\bid\d+\b/)[0].replace('id','');
    
        $("#item_price").html(singleValues);
        $("#price").val(singleValues);
        $('#product_sku').val(singleSKU);
        $('#product_id').val(singleID);
    }
    $("select").change(displayVals);
    displayVals();
    

    Here is a working example →

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

Sidebar

Related Questions

hey guys having this really simple problem but cant seem to figure out have
Hey having some trouble trying to maintain transparency on a png when i create
Hey folks I am trying to implement a search functionality in a website using
Hey am just curious to know if this can be done! I want to
Hey right now I'm using jQuery and I have some global variables to hold
hey guys i know this may sound stupid, but i am stuck with this
hey all.i'm newbie at this problem.i have this data in table result: item range_code
Hey guys, I'm using GWT for a data-driven web application, and I'm having issues
Hey.. I've run into a problem using several like in my sql-query (generated with
Hey guys this is my html code: <div class=nakupy> <li class=icn_kategorie><a href=#>Nákupy</a> <div class=sub_menu>

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.