10

You have a race condition here - once the onclick handler completes the command button will continue with its normal flow and submit the form. Thus both the commandbutton and the actionfunction components will both try to submit the form, and as the commmandbutton goes first I'd expect it to win, although its not an exact science. If you want to use an ...


7

It won't work like this and here is why: Your action in the actionFunction returns a pagereference. But you also specify a rerender (Which you need to pass the parameter). This rerender prevents the page from redirecting because it rerenders a non-existing part of the page. What you can do is not use an actionfunction but change the commandButton to: <...


6

I think you should use explicit reference so it doesn't breaks while packaging. PageReference p = Page.TheVisualforcePage; p.getParameters().put('id', caseId); Daniel Ballinger has an excellent post on this: Safe URLs for custom buttons and page references


6

try action="{!quickSave}" Standard Controller action


6

You can store the required image in static resource and use it in command button in the following way <apex:commandbutton image="{!URLFOR($Resource.Required_Image)}" id="SaveChanges" reRender="productstable" action="{!saveProducts}"/>


6

You should set the btnDisabled class name, as well as setting "disabled". Here's a live example for you to use: <apex:page standardStylesheets="true" lightningStylesheets="false" showHeader="true" > <apex:form> <script> function disableOther() { var btn = document.querySelector("[id$='btn2']"); ...


5

I believe this.form.reset is in fact resetting your form, but the trouble is, when the "Quote List" button is pressed, to call the controller action showList, this is SETTING your values on the page to their variables in the controller. For example: Form is blank (text value in controller empty) Enter text (text value in controller empty) If you click ...


5

Pretty sure it is related to this issue/bug re Command Buttons and Action Regions. I just tried a short version of your code with the button wrapped in an actionregion, and it then worked for me.


5

Catch the enter-key at your inputText with the onkeypress-handler and trigger a fake-click on the button: <script> function handlerKeyPress(ev) { if (window.event && window.event.keyCode == 13 || ev.which == 13) { $('.myUniqueSubmitButtonClass').click(); return false; } else { return ...


5

Why not using JavaScript? Either you can store the previous URL in localStorage and go back there later with document.location or try simply to use window.history.back() http://www.w3schools.com/jsref/met_his_back.asp


5

You can accomplish this with two buttons and the addition of a second parameter to the URL for the GrantDoc VF page. I would suggest using the ISO 639 language code to keep the language values standardized. Examples English: <apex:commandButton onClick="window.open('/apex/GrantDoc?id={!Grant__c.Id}&lang=en');" id="printButtonEN" value="Print Grant ...


5

One way use action status. Display loading symbol unit your process is not completed. <apex:actionFunction action="{!startRequest}" name="startRequest_JS" reRender="result" oncomplete="startRegistration_JS() ;" status="counterStatus"/> <apex:actionFunction ...


5

Values from your page are sent to a controller on form submit. You can see this if you view HTML code generated by your visualforce page <apex:commandButton/> will be an input with type="submit". So try changing the type of your button: <input type="submit" class="button-a blue" onclick="initiateMethod();" value="save"/>


5

Put the below code in the controller action method that is being called on click of command button PageReference pr = new PageReference('/apex/yourVFPageName'); pr.getParameters().put('key','value'); pr.setRedirect(true); // If you want a redirect. Do not set anything if you want a forward. return pr; Edit: In the constructor of the 'yourVFPageName' page ...


5

Make the variable "doc" static to avoid view state error


5

You can't specify parameters as you would when calling a method directly from Apex Code. Instead, you have to use apex:param, as shown here: <apex:commandButton action="{!sendEmail}" value="Send Email" reRender="target"> <apex:param name="addressInput1" assignTo="{!addressInput}" value="param1" /> <apex:param name="subjectInput1" ...


5

No, that's expected. In fact, this probably shouldn't work at all, because you're prematurely cancelling the actionFunction (it's asynchronous). What you end up with is a situation that's a race condition; will the network callout reach the server before the page unloads (which automatically terminates all network activity)? Instead, make sure you put ...


5

Take a look at the apex:actionFunction. This allows you to generate a JavaScript function and to call this function from JavaScript in your page (e.g. in an onclick event). The parameters to the function can be bound (or "assigned") to properties on the controller, and these will be updated before the associated method is called on the controller. Please do ...


4

Command buttons translate to form input submit buttons. Hence they have a default behavior to submit the form when clicked, which is conflicting with your javascript call. If you change the call to onclick="JSetString(); return false;" as @mast0r pointed out the return false prevents the onclick event from bubbling up to the form and should fix your issues....


4

Try this instead: When you define parameter to actionfunction then action javascript accept it as argument. <apex:page controller="TestActionFunctionWithoutAction"> <apex:form> <apex:commandButton title="Apply and Continue" value="Apply and Continue" onclick="setState()" rerender="xyx"/> <apex:actionFunction ...


4

This is how you would make sure you are using jQuery (in this case taken from a CDN location): <apex:includeScript value="https://code.jquery.com/jquery-1.11.0.min.js"/> <script> var j$ = jQuery.noConflict(); function getSelectedContact() { var $radio = j$('input[name=group1]:checked'); var selected = $radio.attr('id'); afAssign(...


4

Even though you only have 1 SOQL statement in your code it gets executed 3 times, once for every call to Count(). If you use a map where the key is the status and the value is the count you can do something like the code below. This code will only execute the SOQL once. Ordered Items: <apex:commandButton value="{!statusCount['Ordered']}"/> ...


4

Your first condition is wrong if you are doing NOT in your condition correct syntax is rendered="{!!hasuser}"


4

Change your javascript function name from new() to something else say new_method() as new is a keyword. It will work.


4

If these are all fields that live directly on your custom object, then you can just use the standard controller on your custom object, and then invoke the standard {!save} function on a commandButton/link/etc Something like this... (Note, have not attempted to compile code, wrote on the fly): <apex:page standardController="O1__c"> <apex:...


4

There's no such CSS value for "float" of "center." If you want your commandButton to be in the middle of the area, you should do something like this: <div style="text-align: center"> <apex:commandButton ... /> </div> Edit: You have to also wrap the item inside a pageBlockSectionItem. Here's a demo page that works. <apex:page > ...


4

Need to be add a DummyID for reRedner. <apex:page controller="clicktest"> <apex:form> <apex:commandButton action="{!Stats_In}" value="click" reRender="dummyId"> <apex:param name="MS_Item" value="MS_Item_45382" assignTo="{!MS_Item}" /> </apex:commandButton> </apex:form> </apex:page>


4

use reRender attribute on apex:commandButton here is a nice article Implementing Partial Page Updates with Command Links and Buttons where all required steps are listed First, create or identify the portion of the page that should be rerendered. To do this, wrap the tag in an <apex:outputPanel> tag, and give the output panel an id parameter. The ...


3

<apex:commandButton value="Do something" onclick="actionFunction(); return false;" /> <apex:actionFunction name="actionFunction" action="{!action}" rerender="someArea" />


3

Visualforce does not allow you to change the default command button. It would in fact be difficult, because the default behavior comes from the browser. In most browsers, if enter is pressed while in an input field, the first input type="submit" element is selected. The problem is that Visualforce renders all commandButtons with type="submit". Knowing ...


Only top voted, non community-wiki answers of a minimum length are eligible