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

Command button won't call javascript

Hi All,


I'm having a problem with my visual force page whereby i'm simply trying to get a command button to call a test javascript function, and it just doesn't want to play! i've managed to do it on other VF pages i have, but for some reason here it just won't work. Hopefully it's something dead simple that i've just missed because i've been staring at it for so long!


The page is of the form:



<apex:page controller="AController" extensions="AControllerExt" >
<apex:form id="form">
<h1>Some text here</h1>
<apex:outputLabel>Label text here</apex:outputLabel>
<apex:commandButton value="ButtonText" onmousedown="test()"/>


function test() {

alert('in test function');





Just to clarify, I don't get the alert box popping up, the page just refreshes.


Any ideas?






Message Edited by mt0859 on 05-27-2009 10:03 AM
Message Edited by mt0859 on 05-27-2009 10:04 AM

Try this but you may be better off using a regular html button to call this type of javascript method:








Hi.. I am also facing similar kind of problem in my code..even "onclick" event also not working..


any idea???

Anyone found a workaround or cause of this issue? I am having the some problem!

me too!


Soozee wrote:

me too!

use onclick="test(); return false;"


also see my thread if your issue include param and class variables:


FYI: This works just fine. (Without the return false; after the alert, the page refreshes)


<apex:commandButton value="Alert Me" onclick="test(); return false;" />
function test(){
   alert('Got it');