close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Restricting the Quantity field to be an integer

Thread began 8/04/2015 7:11 am by djellis267466 | Last modified 8/04/2015 1:50 pm by Ray Borduin | 78 views | 1 replies |

djellis267466

Restricting the Quantity field to be an integer

I have a very old eCart application (probably started with v3 and has had only minor changes since).

I want to restrict the Quantity field to be an integer only. I know the correct method of doing this with v5 would be to select integer from the eCart object for the Quantity field. However when I do this I get fatal errors elsewhere in the application.

I found an old thread from Jason (http://www.webassist.com/forums/posts.php?id=9892) that recommended doing a coding change in the eCart object. This would be my preferred solution.

Change:-
if (isset($_POST[$this->CartName."_Quantity_".$n])) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_".$n]);
}

to:-
if (isset($_POST[$this->CartName."_Quantity_".$n]) && is_int($_POST[$this->CartName."_Quantity_".$n)) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_".$n]);
}

However when I try this then DW is reporting a syntax error. However I can't see any reason for the syntax error.
The code where I am making the change is this;-

$itemQuantity = null;
if (isset($_POST[$this->CartName."_Quantity_hid_".$n])) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_hid_".$n]);
}
if (isset($_POST[$this->CartName."_Quantity_list_".$n])) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_list_".$n]);
}
if (isset($_POST[$this->CartName."_Quantity_".$n])) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_".$n]);
}
if (isset($_POST[$this->CartName."_Quantity_check_".$n])) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_check_".$n]);
}

Any suggestions would be much appreciated.

Sign in to reply to this post

Ray BorduinWebAssist

Just change floatval to intval and don't change anything else and it should do the trick. Decimals will just be ignored.

Sign in to reply to this post

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...