function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
FrustratedDevFrustratedDev 

Needing help with S-control: Showing / hiding fields

Hi,

I'm having a bit of a problem implementing my first S-control. The syntax below is correct but it shows the button whatever. Below is the code I've tried so far:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Demo Button</title>
<!-- common Salesforce stylesheet --><link href="/sCSS/12.0/Theme2/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet">
</head>
<body style="background-color:#F3F3EC;">
<div style="padding-left: 115px;!IF(NOT(ISPICKVAL( Opportunity.Category__c ,"Consultancy"))),"display: none;"}">
<input value=" Enter Shipping Details " class="btn" name="demo_button" onclick="JavaScript: alert('Thanks for clicking!');" title="Create New Account button" type="button">
</div>
</body>
</html>

 I tried some code which works for a checkbox which works but I'm trying it for a picklist as above. If the category is "Consultancy" in the picklist, I wish to show the button and hide it in any other circumstances.I don't know if it's anyhting to do with the braces but for some reason the syntax is incorrect if I place an opening brace in front of the !IF saying a } is expected. I have tried just about everything I can thik of to no avail. Can anybody help with this line of code please?

Many thanks

devNut!devNut!
Another approach you can try is to define the onLoad javascript function in the body tag.
In this function you check the value of the Opportunity.Category__c field and manipulate the div as required.

e.g

Code:
<head>

<script>
function init()
{
if( "{!Opporunity.Category__C}"=="Consultancy" )
document.getElementById("mainDiv").style.display="block";
}

</script>


</head>

<body onload="init()">

<div style="padding-left: 115px; display:none" id="mainDiv">
<input value=" Enter Shipping Details " class="btn" name="demo_button"
onclick="JavaScript&colon; alert('Thanks for clicking!');"
title="Create New Account button" type="button">
</div>

</body>

 
Note the div is hard coded as not visible and is turned on if the condition is met.

FrustratedDevFrustratedDev
Hi,

You are a star. Many thanks for that. However, the "Thanks for clicking" message does not appear.

Can you help me a bit further please - it's much appreciated. What I really want is for an editable field or pop-up to appear that the user can fill in with the shipping address and it adds it to the opportunity layout. Sorry for asking a lot!

Many thanks
Scott
devNut!devNut!
Within the DIV tag you could put a full set of HTML form tags that let the user enter information.

What you do with that information (e.g. write it back to salesforce) is up to you.
filmfxfilmfx
Can you tell me where you install the s-control. I am new to this and trying to do osmething similar.

I want to make some fields hide when a check box is checked in an account. I just can't seem to reverse engineer the code to get it right.

If the condition is True (checked) I want to hide the field Logger_station_Pool.

Any help would be greatly appreciated!

Thanks

This is what I have:


<head>

<script>
function init()
{
if( "{!Account.Is_this_a_Production_or_Show__c}" = "True" )

document.getElementById('Logger_Station_Pool').style.display="block";

}

</script>

</head>
devNut!devNut!

You can install it under: Setup -> App Setup -> Develop -> S-Controls


Are you calling the init() function from somewhere ?

It might be better to make the section default off and enable it if the condition is met.
filmfxfilmfx
Thanks for the reply but I may have not been clear. I actually already built it in the correct location as you mentioned, I guess what I need to know is how to deploy it. Once it is written correctly, where do I place the finalized s-control?