Change Add button dynamically on Add Page

Hi All!I want to do some modification on Add Page, kindly guide me how to do?

  1. I want to hide / show button after click on Particular Radio button.
  2. On the basis of selection of Radio button I want to change the caption of “Add” Button like: I have Radio button which contains option Online / Offline if user select Online then Button name display “Pay” otherwise “Submit”
  3. On the basis of selection I want to change the button action of Add button like: I have Radio button in that user can select → Online / Offline; if user select online it will redirect to other page after clicking on Add Button, Other wise it will just submit.

You may use Client Side event (see the topic Field Setup → Edit Tag → Client Side Events in the help file) to add your jQuery code to:

  1. Show/hide the original submit button, see: https://api.jquery.com/toggle/#toggle-display
  2. Change the caption, see: https://api.jquery.com/html/
  3. Hide the original submit button, and add your own button (with onclick event for redirection), see:
    https://api.jquery.com/category/manipulation/dom-insertion-outside/
    https://api.jquery.com/click/

Thank You for your reply! I tried also but I did not success can You please explain one by one.Once again I am writing my question(s)— Motto - I want to link this page from Payment Gateway System for that I have Given 2 option to customer in Radio button 1. Online / 2. OfflineCondition 1.
By default Add Button should be hide

Condition 2
after selecting Online form Radio button → Add Button should be visible with caption “Pay Online” if User select Offline then button should be visible with caption "Submit"Condition 3
after selecting Online if Customer Click on Button then it should be saved and redirect to Payment Gateway page and save data temporary basis.Condition 4
If user select Offline and click on button then simply save the data in database.Thank you in advance.

I write this code in Client Script->Table-Specific->Add/Copy Page->Startup Script

$(document).ready(function(){
$(“#btn-action”).hide(); // Default Hide Add Button
$(“#x_PaymentMode”).change(function() {
var str = $(“option:selected”, this);
if (this.value == “1”) { // Selection of Radio Button
$(“#btn-action”).show); // Show the Add Button
Language()->setPhrase(“AddBtn”, “Pay Online”); // Change name of button as “Pay Online”
} else {
Language()->setPhrase(“AddBtn”, “Submit”); // Change name of button as “Submit”

}
});
});

Please guide me where I am wrong?

You cannot mix PHP code in JavaScript, you should write in pure JavaScript.
arbei wrote:

Change the caption, see: https://api.jquery.com/html/

arbei wrote:

You cannot mix PHP code in JavaScript, you should write in pure JavaScript.

Not always. If the Javascript code put in “Startup Script” under the “Add/Copy Page”, then you should be able to mix the PHP Code inside your Javascript code. Just enclose your PHP Code with the <?php ... ?> tags.

@sanjeev

You cannot use <?php Language()->setPhrase(...) ?> in JavaScript because the PHP code is run on server side when the page is loaded and the phrase is always set to the last one, in your case, “Submit”. To change the caption by JavaScript, arbei wrote:

Change the caption, see: https://api.jquery.com/html/