You need to sign in to do that
Don't have an account?
Ap30
how to call javascript function based on button click
Hi All,
In my below code, I have to call tow javascript functions "amtValidation() and clickMe()" inside javascript "nameValidation". These functions should be called based on the button click. when "send" button is clicked it has to call amtValidation(), and when "click Me" is clicked it has to call clickMe(). Please help.
============
<apex:page controller="Bookings" id="page">
<script>
function nameValidation(){
var n = document.getElementById('{!$Component.page.form.pb.pbs.name}');
alert(n.value);
if(n.value == "")
{
alert("Name is mandatory");
return false;
}
else{
alert("enter name else");
amtValidation();
clickMe();
}
}
function amtValidation(){
//process here
}
function clickMe(){
//process here
}
<apex:form id="form">
<apex:actionFunction action="{!send}" name="send" reRender="pb" />
<apex:actionFunction action="{!clickme}" name="clickme" reRender="pb"/>
<apex:pageBlock title="Vendor Registration Form" id="pb">
<apex:pageBlockSection columns="2" id="pbs">
Name :<apex:inputText value="{!vcperson}" id="name"/>
</apex:pageBlockSection>
<apex:outputPanel id="op">
<apex:commandButton value="Send" id="email" action="{!send}" onclick="return nameValidation();return amtValidation()"/>
<apex:commandButton value="Click Me" id="pdf" action="{!clickme}" onclick="return nameValidation();return clickMe()"/>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
In my below code, I have to call tow javascript functions "amtValidation() and clickMe()" inside javascript "nameValidation". These functions should be called based on the button click. when "send" button is clicked it has to call amtValidation(), and when "click Me" is clicked it has to call clickMe(). Please help.
============
<apex:page controller="Bookings" id="page">
<script>
function nameValidation(){
var n = document.getElementById('{!$Component.page.form.pb.pbs.name}');
alert(n.value);
if(n.value == "")
{
alert("Name is mandatory");
return false;
}
else{
alert("enter name else");
amtValidation();
clickMe();
}
}
function amtValidation(){
//process here
}
function clickMe(){
//process here
}
<apex:form id="form">
<apex:actionFunction action="{!send}" name="send" reRender="pb" />
<apex:actionFunction action="{!clickme}" name="clickme" reRender="pb"/>
<apex:pageBlock title="Vendor Registration Form" id="pb">
<apex:pageBlockSection columns="2" id="pbs">
Name :<apex:inputText value="{!vcperson}" id="name"/>
</apex:pageBlockSection>
<apex:outputPanel id="op">
<apex:commandButton value="Send" id="email" action="{!send}" onclick="return nameValidation();return amtValidation()"/>
<apex:commandButton value="Click Me" id="pdf" action="{!clickme}" onclick="return nameValidation();return clickMe()"/>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
Please follow below code:
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
All Answers
Please follow below code:
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
<head>
<script type = "text/javascript" src="function.js"></script>
</head> myccpay (https://www.acesetm.biz/)
<body>
<p>Click the following button to see the function in action</p>
<input type = "button" onclick = "myfunction()" value = "Display">
</body>
Where is your highlited code. Please share me
For pdf you need to add renderAs="pdf"
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh