VAP1 Posted August 31, 2015 Report Share Posted August 31, 2015 Hi all, I want to hide the submit button in a details page based on the value of five calculated fields. I saw this post from before: http://forums.caspio.com/index.php/topic/5131-hide-button-based-on-calculated-field/ Based on the advice there, I came up with the following: <script language="javascript">var stat='[@calcfield:2]';if (stat.length='Not Equal, please revise figures'){coauthor = stat;document.write(stat);document.getElementById("Mod0EditRecord").style.display = "none";}</script> But I have been unable to get that script to work for me properly. As is, it does not hide the submit button but rather shows the button and the text "Not Equal, please revise figures" below the submit button.(see attached) Also, the script is for only one calculated field and I would like the javascript to include five. Any help would be much appreciated. DanielRom 1 Quote Link to comment Share on other sites More sharing options...
Aurora Posted September 3, 2015 Report Share Posted September 3, 2015 Hello VAP1 How you doing? Here is a sample of script if you have 2 Calculated fields : <SCRIPT LANGUAGE="JavaScript"> var stat='[@calcfield:1]'; var stat2='[@calcfield:2]'; if (stat>10&&stat2>10) { document.getElementById("Mod0EditRecord").style.visibility = 'hidden'; alert ("Not Equal, please revise figures"); } </script> Could you please verify, what exactly you want to do with Calculated Fields? I mean if you want them do be all equals to each other, or you want to allow a submit button if they all have values more then 10 ( like it does in my script) ? Aurora VAP1 1 Quote Link to comment Share on other sites More sharing options...
VAP1 Posted September 8, 2015 Author Report Share Posted September 8, 2015 Hi Aurora, thanks for your help! Each calculated field listed in the script below compares 2 or more calculated fields not listed and basically checks to make sure the user filled out the form correctly. What I want is that they do not allow the submit button if the the calculated fields do not read "OK" Based on what you provided I was able to put together the following, which worked on its own but not when deployed with other datapages on the same page: <SCRIPT LANGUAGE="JavaScript"> var stat='[@calcfield:2]'; var stat4='[@calcfield:4]'; var stat6='[@calcfield:6]'; var stat8='[@calcfield:8]'; var stat10='[@calcfield:10]'; if (stat!='OK' || stat4!='OK' || stat6!='OK' || stat8!='OK' || stat10!='OK') { document.getElementById("Mod0EditRecord").style.visibility = 'hidden'; } </script> Do you have any advice on why it works deployed by itself and not with other data pages?? thanks again! Quote Link to comment Share on other sites More sharing options...
Aurora Posted September 8, 2015 Report Share Posted September 8, 2015 Hi VAP1 Glad that it helped! What type and how many DataPages do you deploy on the webpage? The script might not work if we use IDs of the elements of few DataPages. Could you please give me the URL of the web page, i will take a look. Or you could send it to me in personal message here. Best, Aurora VAP1 1 Quote Link to comment Share on other sites More sharing options...
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.