Jump to content
  • 0

How Can I Disable A Button Based On Calculated Results In A Field


Stepford
 Share

Question

Hi there,

In the App I am currently developing I have a "View Inventory" DataPage where my users can see (for a chosen product) what the starting inventory was A, how many units are reserved / shipped B and finally how many units are available C.
C is a calculated field where C = A - B
On this page I also have an HTML block with a control button that my users can click to create a shipment request, but I want this to be disabled when C = 0 because as it stands right now, there is nothing stopping them from ordering an item that is out of stock.

The current code for my button is as follows:

'<div style="margin: 10px;"><a href="http://eu1.caspio.com/dp.asp?AppKey=cde830001d57b1a237854adab459&Stock_ID=[@field:Stock_ID]&Product_Description=[@field:Product_Description]" style="background: rgb(61, 130, 171); padding: 7px 20px; border: 1px solid rgb(221, 221, 221); border-image: none; color: rgb(255, 255, 255); font-weight: bold; text-decoration: none; white-space: nowrap;">Create Shipment Request</a></div>'

I read on another post on here that the way to address this was to use Javascript, so following that advice I changed the code for my button the the following:

<script type="text/javascript">
var cb_boolean = '[@calcfield:1]';
if (cb_boolean != '0')
{
document.write("<input type='button' value='Create Shipment Request' Name='mybutton' onclick='myfunction()'> ");
}
else
{
document.write("<input type='button' value='Out Of Stock!' Name='mybutton' disabled=true>");
}
function myfunction()
{
window.location.href='http://eu1.caspio.com/dp.asp?AppKey=cde830001d57b1a237854adab459&Stock_ID=[@field:Stock_ID]&Product_Description=[@field:Product_Description]';
}
</script>


This worked in terms of disabling my button where C = 0, but then the parameters were no longer being passed to my shipment request DataPage.
I suspect this is a syntax error of some sort, but being a newbie to the worlds of both HTML and Javascript I just don't know what I need to change.

Any advice would be much appreciated

Thanks :)

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...