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
NikunjVadiNikunjVadi 

command button functionality issue

hey,

i am having problem calling the fuction from controller and script using actionfunction. if i am using command button without actionfunction, everything is working fine. but with actionfuction nothing is getting executed . 
Code
<apex:page standardController="Project_Time__c" extensions="SwitchProject_Controller">
     <apex:includeScript value="{!$Resource.modernizr}"/>
   
    <script>
        function doTheGeoThang()
            {
            if (Modernizr.geolocation){
                navigator.geolocation.getCurrentPosition(
                function(position) {
                    loc(position.coords.latitude,position.coords.longitude);
                }
                );
            }
            else 
            {
                alert ("Your browser isn't hit. Upgrade man!");
            }
            }
    </script>
<apex:form >
<apex:pageblock >
<apex:pageBlockSection title="Switch Project" columns="1">
<apex:actionregion >
<apex:commandButton onclick="doTheGeoThang();" value="Switch Project"/><br/>
                        <apex:actionFunction name="loc" action="{!SwitchProject}" rerender="jsvalues">
                        <apex:param name="lat" value="" assignTo="{!valueLat}"/>
                        <apex:param name="long" value="" assignTo="{!valueLong}"/>
                        </apex:actionFunction>
</apex:actionregion>
<apex:inputField value="{!Project_Time__c.Project__c}" />

</apex:pageBlockSection>
 

</apex:pageblock>
</apex:form>
</apex:page>

thanks
Shrikant BagalShrikant Bagal
hello NikunjVadi,

As per your code your are reRender "jsvalues" and I didn't see any apex tag with "jsvalues" id.

FYI:
- As you are using "actionRegion" tag, Please take care of The "jsvalues" id Tag should be wrapped in <apex:actionRegion> tag.

Hope its help!!

Thanks!
NikunjVadiNikunjVadi
hey, thanks for the reply. 

this code is working :
<apex:form >
                <apex:actionRegion >
                    <center><apex:commandButton value="Punch In" onclick="doTheGeoThang1();"/></center>
                        <apex:actionFunction name="loc1" action="{!PunchIn}" rerender="jsvalues">
                        <apex:param name="lat" value="" assignTo="{!valueLat}"/>
                        <apex:param name="long" value="" assignTo="{!valueLong}"/>
                        </apex:actionFunction>
                </apex:actionRegion>
                <apex:actionRegion >
                     <center><apex:commandButton value="Punch out" onclick="doTheGeoThang2();"/></center>
                        <apex:actionFunction name="loc2" action="{!PunchOut}" rerender="jsvalues">
                        <apex:param name="lat" value="" assignTo="{!valueLat}"/>
                        <apex:param name="long" value="" assignTo="{!valueLong}"/>
                        </apex:actionFunction>
                </apex:actionRegion>

but above isn't . why? 
NikunjVadiNikunjVadi
when i gave id to actionregion. it works. so thanks. but why other one isn't working without any id?
Shrikant BagalShrikant Bagal
Hello NikunjVadi,

salesforce use the Id specified in reRender attaribute use for Render that tag once AJAX request is completed, so when you are not specified Id salesforce render nothing.

Hope its clear your question.

Please mark as best answer if its resolved your issue. Its help other if they surve same problem.

Thanks!