close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Why would my total price column always update with a number 2?

Thread began 6/02/2020 12:08 pm by lr_leal239405 | Last modified 6/03/2020 5:47 pm by Ray Borduin | 53 views | 11 replies |

lr_leal239405

Why would my total price column always update with a number 2?

Do you have any insight as to why my code for updating on an AJAX call would always populate my Total Price column with a Number 2. Even when I explicitly write in an amount, it updates with a '2.00'. Below is the update code and the Ajax function:


<?php
$q = $_GET['q'];
$OptIDhid = $_GET["OptIDhid"];
$OptTotalPrice = $_GET["OptTotalPrice"];
?>
<?php
if (true) {
$UpdateQuery = new WA_MySQLi_Query($convacc_cx);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "cac_quote_new_optionals";
$UpdateQuery->bindColumn("quantity", "i", "". $q ."", "WA_BLANK");
$UpdateQuery->bindColumn("totalprice", "d", "". number_format(100.55,2) ."", "WA_BLANK");
$UpdateQuery->addFilter("optional_id", "=", "i", "". $OptIDhid ."");
$UpdateQuery->execute();
}
?>



// AJAX CALL

<script>
function changeOptsQty(str,optid,c) {
if (str == "") {
//document.getElementById("TotalOptsPrice").innerHTML = "";
return;
} else {
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//document.getElementById("TotalOptsPrice").innerHTML = this.responseText;
}
};
xmlhttp.open("GET","changeOptsQty.php?q="+str + "&OptIDhid="+ optid + "&OptTotalPrice="+ c ,true);
xmlhttp.send();
}
}
</script>

I put a random number (with decimal or no decimal places "100.55". It is originally $OptTotalPrice but I still get '2.00' in column.

Thanks for any insight into this.

Sign in to reply to this post

Ray BorduinWebAssist

I don't see what would cause this. I'd need a URL and FTP access to debug. Perhaps I missing something, or maybe there is other code somewhere effecting it.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

you can get all files here

Attached Files
converteraccessory.com CAC SERVER QUOTES TEMPUSR.ste
Sign in to reply to this post

Ray BorduinWebAssist

I can't seem to log in to see the page with those credentials.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

sorry

Attached Files
converteraccessory.com CAC SERVER QUOTES TEMPUSR.ste
Sign in to reply to this post

Ray BorduinWebAssist

I see that the update page is working. If I go directly to the url (listed in the private area) then the price is updated properly.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

oh...Yes. The Total Price displays correctly on that page when on onBlur. I'm trying to grab that Value and put it in the database. The database gets a '2.00', not that value.

Sign in to reply to this post

Ray BorduinWebAssist

I'm talking about skipping that page entirely. When I go to the ajax update page and check the database it is correctly updated. See the url in the private area for reference.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

if you go directly to the changeOptsQty.php page, the update happens fine.

If you go through the Ajax function, the Quantity column is updated correctly, but the totalprice column updates to a '2.00'

I'm looking at the actual table. When I test, I get a '2.00'.That's what I'm confused about.

Sign in to reply to this post

lr_leal239405

What I was trying to do is get the Total Price

Price * Quantity

updated on the table.

It displays after JavaScript onBlur on the page itself and updates the Quantity onBlur on the database correctly, and also updates the TotalPrice on the db, incorrectly, with a '2.00'. I don't know where that 2.00 is coming from.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...