Jump to content

Hide Submit Button Based On Various Calc Fields


Recommended Posts

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.

 

 

post-17876-0-78786100-1441040546_thumb.p

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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
Reply to this topic...

×   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...
×
×
  • Create New...