Jump to content

AJAX & Mysql - to Update text fields in forms, not just data.


tdors

Recommended Posts

I’ve been searching and toying with this solution for some time but can’t find that right answer.  Looking for solutions/suggestions to the following:

 

I created a program that will allow people to track sales and depending on what they’ve sold, they will either get a set bonus, or a bonus based on a percentage.  I have no problem creating a drop down box for them to select from, and I could probably create a select button that would do the action, but I’d rather have it in one step.  So what I’m trying to do is somehow when they select from the drop down (via a JavaScript onchange or something) I’d like it to pull data from the MySQL database and then update a locked text box that shows the $ amount.  I’d like it to pull the amount and then each or per based on the ID of what they’ve selected from the drop down.  If it was always based on each sale or based on a percentage, that would be easy as I could code that into the drop box, but I’d like to keep it based on the ID so that it can pull out of the database the name, and then when changed pull the info.

 

An example is here: http://www.toddspage.com/slex/tracking_csell.php?staff_id=1

 

Field Explanation:

 

Date (Date)

 

Member (Customer Number)

 

Walk In Product (Standard drop down, throwing in data from mysql with the id number (normalized database)), this is what the customer came in for, is just for reference, will have about 30 choices in it

 

X-Sell Product (What was cross sold to the customer, This will have the same data as the Walk In Product, but when the employee selects something from this list, I want it to grab data from mysql, The "Metric" and the "Each/Per", Metric being dollar amount, Each/Per being the definition of one time spiff, or per thousand spiff.)

 

New Money would be the field used to help calculate the per thousand spiff

 

Metric would be a locked field that gets data from mysql based on the X-Sell Drop down

 

EP Would show Each or Per (would be a single character text box)

 

Subtotal would be locked and calculate the total based on the metric and new money

 

Notes is just notes

 

I can figure out the JavaScript programming to calculate, so that's not a problem, just need help pulling the data from mysql and passing the variables.  I'll try asking in AJAX.  I've been reading a lot on AJAX but haven't found anything on passing variables.

 

I just want to be sure that if they type something in one of the fields, when the drop down changes and updates fields around it, that the data in the fields that are changeable and not updated don't disappear.  Would love to see a working example but I haven't found much like this around.

 

Open to any suggestions.  Thanks!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.