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
Prakash@SFDCPrakash@SFDC 

Java Script Not working in OutputLink

HI ,

 

I am using one output link in which if you click that link that should hide and new  link should appear in the same . If you click the new link again that should hide and the old one should appear vice - vesa . I am giving the sample code below .

 

 <apex:outputLink id="map2" value="javascript&colon;hidemap();"  styleClass="hideMapLink">                         
                         <span>{!$Label.Hide_Map}</span>
                         </apex:outputLink>                         
                           
  <apex:outputLink id="map1" value="javascript&colon;showmap();resizeMap();"  styleClass="showMapLink">
                         <span>{!$Label.Show_Map}</span>
                         </apex:outputLink>
                              
                                     
                      
             <script language="javascript">
                        function showmap()
                        {                       
                        document.getElementById("mapContainer").style.display="block"; 
                        }
                        function hidemap()
                        {                       
                        document.getElementById("mapContainer").style.display="none";
                        }
                        </script>   
                       <div id="mapContainer" class="mapclass" style="display:none">
                          <div id="map" >
                       </div>
                      </div>

 

Initially ShowMap link will Appear . If you click that link one block appear with map loaded in it , and Showmap link has to change to HideMap. And if you clikc HideMap link mapblock should close and showmap link should appear .

 

Now the issue is i am able to open Mapblock but the link was  not changing to HideMap . Please help me how to acheive this.

 

Many Many thanks in Advance .

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Prakash@SFDCPrakash@SFDC

yeah... Its workng . ..  Write the outputlink in div tag and use the Id of that div in the viewmap () function instead outputlink Id

 

 

All Answers

ministe_2003ministe_2003

you don't appear to be performing any action which would cause your desired affect to happen.  you could add a "Rendered" param to the outputlinks and apply a condition, or you could just use the style.display function that you're already using to make them visible/invisible.  Something like

 

function showmap()
{
document.getElementById("mapContainer").style.display="block"; 
document.getElementById("map2").style.display="inline"; 
document.getElementById("map1").style.display="none"; 
}

function hidemap()
{                       
document.getElementById("mapContainer").style.display="none";
document.getElementById("map2").style.display="none"; 
document.getElementById("map1").style.display="inline"; 
}

 

Prakash@SFDCPrakash@SFDC

No .. Its not working . B'Coz 

 

document.getElementById("map2").style.display="inline"; will use only for div tags means , the ID "map2" is not a div id in our case .

ministe_2003ministe_2003

It should work, you might need to get the full path Id.  Try using firebug or IE's built in JS debugger to find the element's full id.  for example, it might be page:pageBlock:map1

Prakash@SFDCPrakash@SFDC

yeah... Its workng . ..  Write the outputlink in div tag and use the Id of that div in the viewmap () function instead outputlink Id

 

 

This was selected as the best answer
ministe_2003ministe_2003

Cool, glad it's working.  As I say, it would have worked if you used the full Id of the outputlink too